Skip to content

Commit 20cdff6

Browse files
committed
nginx bugfix
1 parent 6a663f9 commit 20cdff6

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

entrypoint.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ if [ -n "$PHP_MAX_EXECUTION_TIME" ]; then
126126
echo "max_execution_time = ${PHP_MAX_EXECUTION_TIME}" >> /usr/local/etc/php/conf.d/${PHP_INI_FILE_NAME}
127127
fi
128128

129-
# Status/Ping
130-
if [ -f "/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini" -a "$PHP_SET_OPCACHE_SETTINGS" -eq "1" ]; then
129+
# OPCACHE Settings
130+
if [ "$PHP_SET_OPCACHE_SETTINGS" -eq "1" ]; then
131131
echo ">> set opcache settings"
132132
cat > /usr/local/etc/php/conf.d/55-opcache.ini <<'EOF'
133133
; https://www.php.net/manual/en/opcache.configuration.php
@@ -151,7 +151,6 @@ fi
151151
# Status/Ping
152152
if [ "$PHP_FPM_IS_EXISTS" -eq "1" -a "$ENABLE_PHP_FPM_STATUS" -eq "1" ]; then
153153
echo ">> enabling php-fpm status!"
154-
155154
cat > ${PHP_FPM_CONF_DIR_PATH}/y-status.conf <<EOF
156155
[www]
157156
; status page (example: http://localhost:${PHP_FPM_STATUS_PORT}${PHP_FPM_STATUS_PATH}?json&full)
@@ -316,7 +315,7 @@ if [ "$APACHE_IS_EXISTS" -eq "1" -a "$ENABLE_APACHE_STATUS" -eq "1" ]; then
316315
Require ip 10.0.0.0/8
317316
Require ip 172.16.0.0/12
318317
Require ip 192.168.0.0/16
319-
#Require ip fd00::/7
318+
Require ip fd00::/8
320319
</Location>
321320
</IfModule>
322321
@@ -401,7 +400,7 @@ r /dev/stdin
401400
d
402401
}' "${NGINX_CONF_FILE}" <<EOF
403402
# nginx status
404-
location /nginx_status {
403+
location = /nginx_status {
405404
stub_status on;
406405
access_log off;
407406
allow 127.0.0.1;
@@ -414,7 +413,7 @@ d
414413
}
415414
416415
# nginx ping
417-
location /nginx_ping {
416+
location = /nginx_ping {
418417
add_header Content-Type text/plain;
419418
return 200 'pong';
420419
access_log off;
@@ -457,8 +456,17 @@ fi
457456
if [ "$NGINX_IS_EXISTS" -eq "1" -a "$ENABLE_NGINX_REMOTEIP" -eq "1" ]; then
458457
# https://nginx.org/en/docs/http/ngx_http_realip_module.html
459458
echo ">> enabling remoteip support, use this only behind a proxy!"
460-
nginx_remoteip_string="set_real_ip_from 172.16.0.0/12;\n set_real_ip_from fd00::/8;\n ##REPLACE_WITH_MORE_REAL_IP##\n real_ip_header X-Forwarded-For;\n #real_ip_recursive on;\n"
461-
sed -i "s|##REPLACE_WITH_REMOTEIP_CONFIG##|${nginx_remoteip_string}|g" ${NGINX_CONF_FILE}
459+
sed -i '/##REPLACE_WITH_REMOTEIP_CONFIG##/{
460+
r /dev/stdin
461+
d
462+
}' "${NGINX_CONF_FILE}" <<'EOF'
463+
# enable ONLY behind PROXY (Traefik, other NGINX, Caddy, lighttpd, K8s Ingress, ...) (ngx_http_realip_module)
464+
set_real_ip_from 172.16.0.0/12
465+
set_real_ip_from fd00::/8;
466+
##REPLACE_WITH_MORE_REAL_IP##
467+
real_ip_header X-Forwarded-For;
468+
#real_ip_recursive on;
469+
EOF
462470
fi
463471

464472
####################################################

examples/fpm-nginx-dhi/config/nginx_default.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ server {
4444
}
4545

4646
# nginx status
47-
location /nginx_status {
47+
location = /nginx_status {
4848
stub_status on;
4949
access_log off;
5050
allow 127.0.0.1;
@@ -57,7 +57,7 @@ server {
5757
}
5858

5959
# nginx ping
60-
location /nginx_ping {
60+
location = /nginx_ping {
6161
add_header Content-Type text/plain;
6262
return 200 'pong';
6363
access_log off;

examples/fpm-nginx/config/nginx_default.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ server {
4444
}
4545

4646
# nginx status
47-
location /nginx_status {
47+
location = /nginx_status {
4848
stub_status on;
4949
access_log off;
5050
allow 127.0.0.1;
@@ -57,7 +57,7 @@ server {
5757
}
5858

5959
# nginx ping
60-
location /nginx_ping {
60+
location = /nginx_ping {
6161
add_header Content-Type text/plain;
6262
return 200 'pong';
6363
access_log off;

0 commit comments

Comments
 (0)