diff --git a/docker/init_scripts/docker-entrypoint.sh b/docker/init_scripts/docker-entrypoint.sh index 2aa602268..71d3e8373 100755 --- a/docker/init_scripts/docker-entrypoint.sh +++ b/docker/init_scripts/docker-entrypoint.sh @@ -39,6 +39,13 @@ done export ROMM_BASE_PATH=${ROMM_BASE_PATH:-/romm} export ROMM_PORT=${ROMM_PORT:-8080} +# Set IPV6_LISTEN based on IPV4_ONLY +if [[ ${IPV4_ONLY} == "true" ]]; then + export IPV6_LISTEN="#listen [::]:${ROMM_PORT};" +else + export IPV6_LISTEN="listen [::]:${ROMM_PORT};" +fi + # Replace environment variables used in nginx configuration templates. /docker-entrypoint.d/20-envsubst-on-templates.sh >/dev/null diff --git a/docker/nginx/templates/default.conf.template b/docker/nginx/templates/default.conf.template index 8f8e56deb..8ab4e85dd 100644 --- a/docker/nginx/templates/default.conf.template +++ b/docker/nginx/templates/default.conf.template @@ -23,7 +23,7 @@ map $request_uri $coop_header { server { root /var/www/html; listen ${ROMM_PORT}; - listen [::]:${ROMM_PORT}; + ${IPV6_LISTEN} server_name localhost; proxy_set_header Host $http_host; diff --git a/env.template b/env.template index 82bfc9e8e..e083314da 100644 --- a/env.template +++ b/env.template @@ -113,6 +113,7 @@ WEB_SERVER_KEEPALIVE=2 WEB_SERVER_MAX_REQUESTS=1000 WEB_SERVER_MAX_REQUESTS_JITTER=100 WEB_SERVER_WORKER_CONNECTIONS=1000 +IPV4_ONLY=false # Development only DEV_MODE=true