From eac4d553a92f6c3a80f81476a41af6e5726c7cd7 Mon Sep 17 00:00:00 2001 From: Patrick Georgi Date: Tue, 27 Nov 2018 00:12:12 +0100 Subject: [PATCH] nginx: Allow extending config with overrides To facilitate this, the default redirect at / can be disabled, even if the default remains at redirecting to the webmailer. The extensions are within the host scope and are read from $ROOT/overrides/nginx/*.conf. --- core/nginx/Dockerfile | 1 + core/nginx/conf/nginx.conf | 8 +++++--- docs/compose/.env | 3 +++ docs/compose/docker-compose.yml | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/core/nginx/Dockerfile b/core/nginx/Dockerfile index 7181487e..717cb225 100644 --- a/core/nginx/Dockerfile +++ b/core/nginx/Dockerfile @@ -14,6 +14,7 @@ COPY *.py / EXPOSE 80/tcp 443/tcp 110/tcp 143/tcp 465/tcp 587/tcp 993/tcp 995/tcp 25/tcp 10025/tcp 10143/tcp VOLUME ["/certs"] +VOLUME ["/overrides"] CMD /start.py diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index 17d67526..0bc6cf07 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -84,14 +84,16 @@ http { } {% else %} + include /overrides/*.conf; + # Actual logic - {% if WEBMAIL != 'none' %} - {% if WEB_WEBMAIL != '/' %} + {% if WEBROOT_REDIRECT %} location / { - return 301 {{ WEB_WEBMAIL }}; + return 301 {{ WEBROOT_REDIRECT }}; } {% endif %} + {% if WEBMAIL != 'none' %} location {{ WEB_WEBMAIL }} { {% if WEB_WEBMAIL != '/' %} rewrite ^({{ WEB_WEBMAIL }})$ $1/ permanent; diff --git a/docs/compose/.env b/docs/compose/.env index 2100e27a..bd98df31 100644 --- a/docs/compose/.env +++ b/docs/compose/.env @@ -97,6 +97,9 @@ COMPRESSION_LEVEL= # Web settings ################################### +# Path to redirect / to +WEB_DEFAULT=/webmail + # Path to the admin interface if enabled WEB_ADMIN=/admin diff --git a/docs/compose/docker-compose.yml b/docs/compose/docker-compose.yml index b8d15587..72981f81 100644 --- a/docs/compose/docker-compose.yml +++ b/docs/compose/docker-compose.yml @@ -29,6 +29,7 @@ services: - "$BIND_ADDRESS6:587:587" volumes: - "$ROOT/certs:/certs" + - "$ROOT/overrides/nginx:/overrides" redis: image: redis:alpine