diff --git a/Dockerfile b/Dockerfile index de59634..85c709c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,8 +36,12 @@ LABEL org.opencontainers.image.url="https://github.com/alam00000/bentopdf" # global arg to local arg ARG BASE_URL +# Set this to "true" to disable Nginx listening on IPv6 +ENV DISABLE_IPV6=false + COPY --chown=nginx:nginx --from=builder /app/dist /usr/share/nginx/html${BASE_URL%/} COPY --chown=nginx:nginx nginx.conf /etc/nginx/nginx.conf +COPY --chown=nginx:nginx --chmod=755 nginx-ipv6.sh /docker-entrypoint.d/99-disable-ipv6.sh RUN mkdir -p /etc/nginx/tmp && chown -R nginx:nginx /etc/nginx/tmp EXPOSE 8080 diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2dc72bf..1e6b4ab 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -9,3 +9,6 @@ services: ports: - '8080:8080' restart: unless-stopped + # For IPv4-only environments + #environment: + # - DISABLE_IPV6=true diff --git a/docker-compose.yml b/docker-compose.yml index 494eff5..4999418 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,3 +7,6 @@ services: restart: unless-stopped ports: - '8080:8080' + # For IPv4-only environments + #environment: + # - DISABLE_IPV6=true diff --git a/nginx-ipv6.sh b/nginx-ipv6.sh new file mode 100644 index 0000000..f2a5ee5 --- /dev/null +++ b/nginx-ipv6.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# @see: https://github.com/nginx/docker-nginx-unprivileged/tree/main/stable/alpine-slim + +set -e + +entrypoint_log() { + if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then + echo "$@" + fi +} + +if [ "$DISABLE_IPV6" = "true" ]; then + entrypoint_log "Disabling the Nginx IPv6 listener" + sed -i '/^[[:space:]]*listen[[:space:]]*\[::\]:[0-9]*/s/^/#/' /etc/nginx/nginx.conf +fi + +exit 0