Skip to content

Commit fb61310

Browse files
haozhoutianon
authored andcommitted
Enable mod_remoteip and add config for X-Forwarded-For IP address
1 parent a7a0a52 commit fb61310

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

php7.1/apache/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ RUN { \
6262
echo 'html_errors = Off'; \
6363
} > /usr/local/etc/php/conf.d/error-logging.ini
6464

65-
RUN a2enmod rewrite expires
65+
RUN a2enmod rewrite expires remoteip
66+
67+
RUN { \
68+
echo 'RemoteIPHeader X-Forwarded-For' ; \
69+
echo 'RemoteIPTrustedProxy 10.0.0.0/8' ; \
70+
echo 'RemoteIPTrustedProxy 172.16.0.0/12' ; \
71+
echo 'RemoteIPTrustedProxy 192.168.0.0/16' ; \
72+
} > /etc/apache2/conf-available/remoteip.conf ; \
73+
a2enconf remoteip
6674

6775
VOLUME /var/www/html
6876

php7.2/apache/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ RUN { \
6262
echo 'html_errors = Off'; \
6363
} > /usr/local/etc/php/conf.d/error-logging.ini
6464

65-
RUN a2enmod rewrite expires
65+
RUN a2enmod rewrite expires remoteip
66+
67+
RUN { \
68+
echo 'RemoteIPHeader X-Forwarded-For' ; \
69+
echo 'RemoteIPTrustedProxy 10.0.0.0/8' ; \
70+
echo 'RemoteIPTrustedProxy 172.16.0.0/12' ; \
71+
echo 'RemoteIPTrustedProxy 192.168.0.0/16' ; \
72+
} > /etc/apache2/conf-available/remoteip.conf ; \
73+
a2enconf remoteip
6674

6775
VOLUME /var/www/html
6876

php7.3/apache/Dockerfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,15 @@ RUN { \
6363
echo 'html_errors = Off'; \
6464
} > /usr/local/etc/php/conf.d/error-logging.ini
6565

66-
RUN a2enmod rewrite expires
66+
RUN a2enmod rewrite expires remoteip
67+
68+
RUN { \
69+
echo 'RemoteIPHeader X-Forwarded-For' ; \
70+
echo 'RemoteIPTrustedProxy 10.0.0.0/8' ; \
71+
echo 'RemoteIPTrustedProxy 172.16.0.0/12' ; \
72+
echo 'RemoteIPTrustedProxy 192.168.0.0/16' ; \
73+
} > /etc/apache2/conf-available/remoteip.conf ; \
74+
a2enconf remoteip
6775

6876
VOLUME /var/www/html
6977

0 commit comments

Comments
 (0)