Skip to content

Commit 767eae2

Browse files
authored
fix: use X-Real-IP header for remote IP (#1221)
1 parent 11dbca9 commit 767eae2

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ RUN a2enmod rewrite ssl
3636
# Fixes for running on ARM
3737
RUN echo "Mutex posixsem" >> /etc/apache2/apache2.conf
3838

39+
RUN echo "127.0.0.0/8" >> /etc/apache2/trusted-proxies.txt
40+
3941
COPY sample_configs/apache.conf /etc/apache2/sites-available/myradio.conf
40-
RUN a2dissite 000-default && a2ensite myradio && apachectl -S
42+
RUN a2enmod remoteip && a2dissite 000-default && a2ensite myradio && apachectl -S
4143

4244
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
4345

Dockerfile.prod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN openssl req -nodes -new -subj "/C=GB/ST=North Yorkshire/L=York/O=University
2727
RUN a2enmod rewrite ssl
2828

2929
COPY sample_configs/apache.conf /etc/apache2/sites-available/myradio.conf
30-
RUN a2dissite 000-default && a2ensite myradio && apachectl -S
30+
RUN a2enmod remoteip && a2dissite 000-default && a2ensite myradio && apachectl -S
3131

3232
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer
3333

sample_configs/apache.conf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Used to enable local testing. You should of course disable HTTP API access in the real world.
22
<VirtualHost *:80>
33
DocumentRoot /var/www
4+
5+
RemoteIPTrustedProxyList /etc/apache2/trusted-proxies.txt
6+
RemoteIPHeader X-Real-IP
7+
48
Alias /api /var/www/myradio/src/PublicAPI
59
<Directory /var/www/myradio/src/PublicAPI>
610
Require all granted
@@ -36,6 +40,8 @@
3640
ServerAdmin webmaster@localhost
3741
DocumentRoot /var/www
3842

43+
RemoteIPTrustedProxyList /etc/apache2/trusted-proxies.txt
44+
RemoteIPHeader X-Real-IP
3945

4046
Alias /myradio /var/www/myradio/src/Public
4147
<Directory /var/www/myradio/src/Public>

0 commit comments

Comments
 (0)