From 7693b6b44e9e8fa795467f2558fb98570c751f14 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Fri, 8 May 2020 21:39:29 +0200 Subject: [PATCH] Add LISTEN_IPV6 env var (#71) --- doc/docker/environment-variables.md | 1 + rootfs/etc/cont-init.d/03-config.sh | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/doc/docker/environment-variables.md b/doc/docker/environment-variables.md index 350a048..5e1408e 100644 --- a/doc/docker/environment-variables.md +++ b/doc/docker/environment-variables.md @@ -8,6 +8,7 @@ * `MEMORY_LIMIT`: PHP memory limit (default `256M`) * `UPLOAD_MAX_SIZE`: Upload max size (default `16M`) * `OPCACHE_MEM_SIZE`: PHP OpCache memory consumption (default `128`) +* `LISTEN_IPV6`: Enable IPv6 for Nginx (default `true`) * `REAL_IP_FROM`: Trusted addresses that are known to send correct replacement addresses (default `0.0.0.0/32`) * `REAL_IP_HEADER`: Request header field whose value will be used to replace the client address (default `X-Forwarded-For`) * `LOG_IP_VAR`: Use another variable to retrieve the remote IP address for access [log_format](http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format) on Nginx. (default `remote_addr`) diff --git a/rootfs/etc/cont-init.d/03-config.sh b/rootfs/etc/cont-init.d/03-config.sh index 7dab5e2..9647c81 100644 --- a/rootfs/etc/cont-init.d/03-config.sh +++ b/rootfs/etc/cont-init.d/03-config.sh @@ -28,6 +28,7 @@ TZ=${TZ:-UTC} MEMORY_LIMIT=${MEMORY_LIMIT:-256M} UPLOAD_MAX_SIZE=${UPLOAD_MAX_SIZE:-16M} OPCACHE_MEM_SIZE=${OPCACHE_MEM_SIZE:-128} +LISTEN_IPV6=${LISTEN_IPV6:-true} REAL_IP_FROM=${REAL_IP_FROM:-"0.0.0.0/32"} REAL_IP_HEADER=${REAL_IP_HEADER:-"X-Forwarded-For"} LOG_IP_VAR=${LOG_IP_VAR:-remote_addr} @@ -77,6 +78,10 @@ sed -e "s#@UPLOAD_MAX_SIZE@#$UPLOAD_MAX_SIZE#g" \ -e "s#@LOG_IP_VAR@#$LOG_IP_VAR#g" \ /tpls/etc/nginx/nginx.conf > /etc/nginx/nginx.conf +if [ "$LISTEN_IPV6" != "true" ]; then + sed -e '/listen \[::\]:/d' -i /etc/nginx/nginx.conf +fi + # SNMP echo "Updating SNMP community..." file_env 'LIBRENMS_SNMP_COMMUNITY' 'librenmsdocker'