Proxify to webmail only if enabled, related to #40

master
Pierre Jaury 8 years ago
parent 18253b1dd3
commit ec5a75f603

@ -1,3 +1,5 @@
FROM nginx
FROM nginx:alpine
RUN apk add --update nginx-lua && rm -rf /var/cache/apk/*
COPY nginx.conf /etc/nginx/nginx.conf

@ -1,6 +1,6 @@
user www-data;
# Basic configuration
user nginx;
worker_processes 1;
error_log /dev/stderr info;
pid /var/run/nginx.pid;
@ -8,7 +8,11 @@ events {
worker_connections 1024;
}
# Environment variables used in the configuration
env WEBMAIL;
http {
# Standard HTTP configuration with slight hardening
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
@ -36,10 +40,19 @@ http {
return 301 https://$host$request_uri;
}
# Load Lua variables
set_by_lua $webmail 'return os.getenv("WEBMAIL")';
# Actual logic
location / {
if ($webmail != none) {
proxy_pass http://webmail;
}
return 403;
}
location /admin {
proxy_pass http://admin;
}

Loading…
Cancel
Save