From 913a6304a7084e5a1647c9ae868151efa84ef5ad Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Mon, 25 Oct 2021 17:24:41 +0000 Subject: [PATCH] Finishing touches. Introduce /static stub for handling all static files. --- core/admin/Dockerfile | 1 - core/nginx/conf/nginx.conf | 38 +++++++++++++++++------- towncrier/newsfragments/1929.enhancement | 1 + 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/core/admin/Dockerfile b/core/admin/Dockerfile index 1a8ef695..083c0f39 100644 --- a/core/admin/Dockerfile +++ b/core/admin/Dockerfile @@ -39,7 +39,6 @@ RUN set -eu \ && apk del --no-cache build-dep COPY --from=assets static ./mailu/ui/static -COPY --from=assets static ./mailu/sso/static COPY mailu ./mailu COPY migrations ./migrations COPY start.py /start.py diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index ce80a6ae..c7eb377a 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -128,15 +128,6 @@ http { include /overrides/*.conf; # Actual logic - location ^~ {{ WEB_ADMIN }}/sso { - include /etc/nginx/proxy.conf; - rewrite ^{{ WEB_ADMIN }}/(.*) /$1 redirect; - } - location ^~ /ui/webmail { - include /etc/nginx/proxy.conf; - return 302 {{ WEB_WEBMAIL }}; - } - {% if ADMIN == 'true' %} location ^~ /ui { include /etc/nginx/proxy.conf; @@ -149,14 +140,31 @@ http { include /etc/nginx/proxy.conf; proxy_pass http://$admin; } + + location ^~ /sso/static { + include /etc/nginx/proxy.conf; + rewrite /sso/static/(.*) /static/$1 permanent; + } + location ^~ /ui/language { include /etc/nginx/proxy.conf; proxy_set_header X-Forwarded-Prefix {{ WEB_ADMIN }}; proxy_pass http://$admin; expires $expires; } + + location ^~ /ui/webmail { + include /etc/nginx/proxy.conf; + return 302 {{ WEB_WEBMAIL }}; + } {% endif %} + location ^~ /static { + include /etc/nginx/proxy.conf; + rewrite ^/static/(.*) /ui/static/$1 break; + proxy_pass http://$admin; + } + {% if WEB_WEBMAIL != '/' and WEBROOT_REDIRECT != 'none' %} location / { expires $expires; @@ -209,7 +217,7 @@ http { return 301 {{ WEB_ADMIN }}/ui; } - location ~ {{ WEB_ADMIN }}/(ui|static) { + location ~ {{ WEB_ADMIN }}/ui { rewrite ^{{ WEB_ADMIN }}/(.*) /$1 break; include /etc/nginx/proxy.conf; proxy_set_header X-Forwarded-Prefix {{ WEB_ADMIN }}; @@ -217,6 +225,11 @@ http { expires $expires; } + location ^~ {{ WEB_ADMIN }}/ui/static { + include /etc/nginx/proxy.conf; + rewrite {{ WEB_ADMIN }}/ui/static/(.*) /static/$1 permanent; + } + location {{ WEB_ADMIN }}/antispam { rewrite ^{{ WEB_ADMIN }}/antispam/(.*) /$1 break; auth_request /internal/auth/admin; @@ -224,6 +237,11 @@ http { proxy_set_header X-Forwarded-For ""; proxy_pass http://$antispam; } + + location ^~ {{ WEB_ADMIN }}/sso { + include /etc/nginx/proxy.conf; + rewrite ^{{ WEB_ADMIN }}/(.*) /$1 redirect; + } {% endif %} {% if WEBDAV != 'none' %} diff --git a/towncrier/newsfragments/1929.enhancement b/towncrier/newsfragments/1929.enhancement index b21118f7..cd3712b6 100644 --- a/towncrier/newsfragments/1929.enhancement +++ b/towncrier/newsfragments/1929.enhancement @@ -2,4 +2,5 @@ Improved the SSO page. - Now shows the login target. - Added toggle to choose login target. - Made SSO page available separately. SSO page can now be used without Admin. + - Introduced stub /static which is used by all sites for accessing static files.