diff --git a/conf/nginx.conf b/conf/nginx.conf index 1fb2f60..e7dda78 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,51 +1,66 @@ 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=10s; + # this is required to proxy Grafana Live WebSocket connections. + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + 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:9090"; proxy_pass $upstream; } location /grafana { set $upstream "http://grafana:3000"; rewrite ^/grafana/(.*)$ /$1 break; + proxy_set_header Host $http_host; + proxy_pass $upstream; + } + # Proxy Grafana Live WebSocket connections. + location /grafana/api/live/ { + set $upstream "http://grafana:3000"; + rewrite ^/grafana/(.*)$ /$1 break; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; proxy_set_header Host $http_host; proxy_pass $upstream; - proxy_set_header Host $http_host; } location / { 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; } } }