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 COPY nginx.conf /etc/nginx/nginx.conf

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

Loading…
Cancel
Save