From 5097f578551ce7f1c5dfccc4b4fc63621ff9f990 Mon Sep 17 00:00:00 2001 From: kaiyou Date: Sun, 24 Sep 2017 15:43:46 +0200 Subject: [PATCH] Redirect nginx authentication requests to the admin container --- nginx/conf/nginx.conf | 7 +++++-- nginx/start.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nginx/conf/nginx.conf b/nginx/conf/nginx.conf index 895ae023..46b36e1f 100644 --- a/nginx/conf/nginx.conf +++ b/nginx/conf/nginx.conf @@ -46,18 +46,21 @@ http { } location /webmail { + rewrite ^/webmail/(.*) /$1 break; proxy_pass http://webmail; } {% endif %} {% if ADMIN == 'true' %} - location /admin { + location /admin/ui { + rewrite ^/admin/(.*) /$1 break; proxy_pass http://admin; } {% endif %} {% if WEBDAV != 'none' %} location /webdav { + rewrite ^/webdav/(.*) /$1 break; proxy_pass http://webdav:5232; } {% endif %} @@ -66,7 +69,7 @@ http { mail { server_name {{ HOSTNAME }}; - auth_http http://{{ ADMIN_ADDRESS }}/nginx; + auth_http http://{{ ADMIN_ADDRESS }}/internal/nginx; proxy_pass_error_message on; server { diff --git a/nginx/start.py b/nginx/start.py index 15e4fee5..e5e13328 100755 --- a/nginx/start.py +++ b/nginx/start.py @@ -7,6 +7,7 @@ import socket convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) # Actual startup script -os.environ["ADMIN_ADDRESS"] = socket.gethostbyname("admin") +if "ADMIN_ADDRESS" not in os.environ: + os.environ["ADMIN_ADDRESS"] = socket.gethostbyname("admin") convert("/conf/nginx.conf", "/etc/nginx/nginx.conf") os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])