Redirect nginx authentication requests to the admin container

master
kaiyou 7 years ago
parent 94a13aabf0
commit 5097f57855

@ -46,18 +46,21 @@ http {
} }
location /webmail { location /webmail {
rewrite ^/webmail/(.*) /$1 break;
proxy_pass http://webmail; proxy_pass http://webmail;
} }
{% endif %} {% endif %}
{% if ADMIN == 'true' %} {% if ADMIN == 'true' %}
location /admin { location /admin/ui {
rewrite ^/admin/(.*) /$1 break;
proxy_pass http://admin; proxy_pass http://admin;
} }
{% endif %} {% endif %}
{% if WEBDAV != 'none' %} {% if WEBDAV != 'none' %}
location /webdav { location /webdav {
rewrite ^/webdav/(.*) /$1 break;
proxy_pass http://webdav:5232; proxy_pass http://webdav:5232;
} }
{% endif %} {% endif %}
@ -66,7 +69,7 @@ http {
mail { mail {
server_name {{ HOSTNAME }}; server_name {{ HOSTNAME }};
auth_http http://{{ ADMIN_ADDRESS }}/nginx; auth_http http://{{ ADMIN_ADDRESS }}/internal/nginx;
proxy_pass_error_message on; proxy_pass_error_message on;
server { server {

@ -7,6 +7,7 @@ import socket
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ)) convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
# Actual startup script # Actual startup script
if "ADMIN_ADDRESS" not in os.environ:
os.environ["ADMIN_ADDRESS"] = socket.gethostbyname("admin") os.environ["ADMIN_ADDRESS"] = socket.gethostbyname("admin")
convert("/conf/nginx.conf", "/etc/nginx/nginx.conf") convert("/conf/nginx.conf", "/etc/nginx/nginx.conf")
os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"]) os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])

Loading…
Cancel
Save