From 85ad5c570d920ff448d3578095e5a805ab6c2a94 Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Wed, 22 May 2024 14:25:07 +0200 Subject: [PATCH 1/3] Nginx refused to boot when a hostname was invalid --- loadbalancer/templates/nginx.conf.conf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/loadbalancer/templates/nginx.conf.conf b/loadbalancer/templates/nginx.conf.conf index c21d81a3..630314e6 100644 --- a/loadbalancer/templates/nginx.conf.conf +++ b/loadbalancer/templates/nginx.conf.conf @@ -74,10 +74,6 @@ http { server ${INTERNAL_DOMAIN}:5117; } - upstream grafana { - server monitoring_grafana:3000; - } - server { listen 80 default_server; server_name ${TEST_DOMAIN}; @@ -154,15 +150,17 @@ http { } location /grafana/ { - proxy_pass http://grafana; + set $upstream http://monitoring_grafana:3000; + proxy_pass $upstream; } # Proxy Grafana Live WebSocket connections. location /grafana/api/live/ { + set $upstream http://monitoring_grafana:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; - proxy_pass http://grafana; + proxy_pass $upstream; } } } From 2bf4d8299306426eaa1ac19cf098e1a74ebd811d Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Wed, 22 May 2024 14:32:00 +0200 Subject: [PATCH 2/3] Add resolver as well --- loadbalancer/templates/nginx.conf.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/loadbalancer/templates/nginx.conf.conf b/loadbalancer/templates/nginx.conf.conf index 630314e6..661f0c27 100644 --- a/loadbalancer/templates/nginx.conf.conf +++ b/loadbalancer/templates/nginx.conf.conf @@ -150,12 +150,14 @@ http { } location /grafana/ { + resolver 127.0.0.11; set $upstream http://monitoring_grafana:3000; proxy_pass $upstream; } # Proxy Grafana Live WebSocket connections. location /grafana/api/live/ { + resolver 127.0.0.11; set $upstream http://monitoring_grafana:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; From 7b0e599febb785cb58bcd40dee381da58d94d8f0 Mon Sep 17 00:00:00 2001 From: Martin Othamar Date: Wed, 22 May 2024 14:36:42 +0200 Subject: [PATCH 3/3] comment --- loadbalancer/templates/nginx.conf.conf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/loadbalancer/templates/nginx.conf.conf b/loadbalancer/templates/nginx.conf.conf index 661f0c27..49f23cdf 100644 --- a/loadbalancer/templates/nginx.conf.conf +++ b/loadbalancer/templates/nginx.conf.conf @@ -150,14 +150,16 @@ http { } location /grafana/ { - resolver 127.0.0.11; + resolver 127.0.0.11; # Docker DNS resolver + # We use a variable here to avoid Nginx crashing for when the container isn't running set $upstream http://monitoring_grafana:3000; proxy_pass $upstream; } # Proxy Grafana Live WebSocket connections. location /grafana/api/live/ { - resolver 127.0.0.11; + resolver 127.0.0.11; # Docker DNS resolver + # We use a variable here to avoid Nginx crashing for when the container isn't running set $upstream http://monitoring_grafana:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;