From e194b1642a248de2a1ca4d89e1505c13e13db8d8 Mon Sep 17 00:00:00 2001 From: Jeremy Cook Date: Fri, 22 Sep 2023 13:49:02 +1200 Subject: [PATCH] updated to use resolver - prevents nginx process being killed if unable to resolve downstream proxy host --- conf/conf.d/default.conf.template | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/conf.d/default.conf.template b/conf/conf.d/default.conf.template index c0c0746..f2e13d8 100644 --- a/conf/conf.d/default.conf.template +++ b/conf/conf.d/default.conf.template @@ -1,10 +1,7 @@ -upstream api-backend { - server ${NGINX_APP_APIHOSTPORT}; - keepalive 20; -} - server { listen 8080; + set $target ${NGINX_APP_APIHOSTPORT}; + add_header Cache-Control no-cache; location / { @@ -15,7 +12,10 @@ server { } location /api/stocks/csv { - proxy_pass http://api-backend; + resolver ${NGINX_DNS_RESOLVER} valid=300s; + resolver_timeout 10s; + + proxy_pass http://$target; } error_page 500 502 503 504 /50x.html;