From 2d033911a340e145509c770c909958771046b0b9 Mon Sep 17 00:00:00 2001 From: Emmanuel Nyachoke Date: Wed, 10 Jan 2024 21:12:27 +0300 Subject: [PATCH] OZ-457: Fix issue with Nginx crashing when upstream server is not available (#67) --- proxy/default.conf.template | 39 +++++++++++++------------------------ proxy/nginx.conf | 1 + 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/proxy/default.conf.template b/proxy/default.conf.template index c77edf9..5aa03df 100644 --- a/proxy/default.conf.template +++ b/proxy/default.conf.template @@ -28,23 +28,6 @@ upstream backend { server openmrs:8080 max_fails=0; } -upstream odoo { - server odoo:8069 max_fails=0; -} -upstream odoochat { - server odoo:8072 max_fails=0; -} - - - -upstream senaite { - server senaite:8080 max_fails=0; -} - -upstream superset { - server superset:8088 max_fails=0; -} - server { listen 80; @@ -139,18 +122,22 @@ server { proxy_cache_valid 200 60m; proxy_buffering on; expires 864000; - proxy_pass http://odoo; + set $odoo odoo:8069; + proxy_pass http://$odoo; } location / { - proxy_pass http://odoo; - # The following makes the timeout broader - proxy_read_timeout 30000; - proxy_redirect off; + + set $odoo odoo:8069; + proxy_pass http://$odoo; + # The following makes the timeout broader + proxy_read_timeout 30000; + proxy_redirect off; } location /longpolling { - proxy_pass http://odoochat; + set $odoo odoo:8072; + proxy_pass http://$odoo; } } @@ -159,7 +146,8 @@ server { location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://superset; + set $superset superset:8088; + proxy_pass http://$superset; } } @@ -170,6 +158,7 @@ server { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; rewrite ^(.*)$ /VirtualHostBase/$scheme/$host/senaite/VirtualHostRoot/$1 break; - proxy_pass http://senaite; + set $senaite senaite:8080; + proxy_pass http://$senaite; } } \ No newline at end of file diff --git a/proxy/nginx.conf b/proxy/nginx.conf index 852d4a9..aec9e79 100644 --- a/proxy/nginx.conf +++ b/proxy/nginx.conf @@ -25,6 +25,7 @@ http { tcp_nodelay on; keepalive_timeout 65; + resolver 127.0.0.11; include /etc/nginx/conf.d/*.conf; } \ No newline at end of file