diff --git a/conf/nginx.conf b/conf/nginx.conf index 73bddaa..d37b3cc 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,60 +1,49 @@ worker_processes 4; # Show startup logs on stderr; switch to debug to print, well, debug logs when # running nginx-debug error_log /dev/stderr info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 100M; # Built-in Docker resolver. Needed to allow on-demand resolution of proxy # upstreams. - resolver 127.0.0.11 valid=30s; - - upstream appserver { - # fail_timeout=0 means we always retry an upstream even if it failed - # to return a good HTTP response - - server "web:5004" fail_timeout=0; - } - - upstream prometheus { - server "prometheus:9090" fail_timeout=0; - } - - upstream grafana { - server "grafana:3000" fail_timeout=0; - } + resolver 127.0.0.11 valid=10s; server { listen 5081 default_server; + # using variable for upstream servers is mandatory to enfore nginx + # to resolve the name at each query. Otherwise, proxy_pass to + # reloaded/restarted service would fail until the nginx service it + # restarted location /prometheus { - set $upstream "http://prometheus"; + set $upstream "http://prometheus:9090"; proxy_pass $upstream; } location /grafana { - set $upstream "http://grafana"; + set $upstream "http://grafana:3000"; rewrite ^/grafana/(.*)$ /$1 break; proxy_pass $upstream; } location / { - set $upstream "http://appserver"; + set $upstream "http://web:5004"; proxy_pass $upstream; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $http_host; proxy_redirect off; } } }