Skip to content

Commit e37546b

Browse files
committed
Fix (docker): Ensure nginx does not listen on ipv6 in ipv4-only environments
The official nginx images do not listen on ipv6, very likely to avoid nginx crashing on startup in ipv4-only environments: ``` docker run --rm -it nginx:alpine cat /etc/nginx/conf.d/default.conf | grep -i listen ``` Hence, we simply need to detect whether ipv6 is disabled, and not listen on ipv6 if ipv6 is disabled in the kernel or in the container.
1 parent 8bf4727 commit e37546b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

.docker/release/files/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ UPLOAD_MAX_SIZE=${UPLOAD_MAX_SIZE:-25M}
99
MEMORY_LIMIT=${MEMORY_LIMIT:-128M}
1010
SECURE_COOKIES=${SECURE_COOKIES:-true}
1111

12+
# Disable listening on ipv6 for ipv4-only environments, or nginx will fail to start
13+
if ! ip a | grep 'inet6 ' > /dev/null; then
14+
echo "[INFO] ipv6 is disabled. Configuring nginx to not listen on ipv6"
15+
sed -i '/listen \[::\]:/d' /etc/nginx/nginx.conf
16+
fi
17+
1218
# Set attachment size limit
1319
sed -i "s/<UPLOAD_MAX_SIZE>/$UPLOAD_MAX_SIZE/g" /usr/local/etc/php-fpm.d/php-fpm.conf /etc/nginx/nginx.conf
1420
sed -i "s/<MEMORY_LIMIT>/$MEMORY_LIMIT/g" /usr/local/etc/php-fpm.d/php-fpm.conf

0 commit comments

Comments
 (0)