From 2e38e1a79cc3cc7090fb29f4ba4c3e6968288e27 Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Mon, 24 Apr 2023 21:13:01 +0200 Subject: [PATCH] nginx: refactor the config --- src/nginxconfig.ejs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/nginxconfig.ejs b/src/nginxconfig.ejs index 1038377e3..2c7dbf822 100644 --- a/src/nginxconfig.ejs +++ b/src/nginxconfig.ejs @@ -326,13 +326,6 @@ server { } <% } %> - <% } else { %> - location / { - proxy_pass http://<%= ip %>:<%= port %>; - } - <% } %> - - <% if (proxyAuth.enabled) { %> # workaround caching issue after /logout. if max-age is set, browser uses cache and user thinks they have not logged out # IMPORTANT: have to keep all the add_headers at top level here to avoid repeating all the add_headers and proxy_set_headers in location block proxy_hide_header Cache-Control; @@ -344,6 +337,11 @@ server { proxy_set_header X-Remote-User $user; proxy_set_header X-Remote-Email $email; proxy_set_header X-Remote-Name $name; + + <% } else { %> + location / { + proxy_pass http://<%= ip %>:<%= port %>; + } <% } %> <% } else if ( endpoint === 'redirect' ) { %> @@ -393,18 +391,7 @@ server { proxy_ssl_verify off; proxy_pass $upstream; } - <% } else { %> - location / { - # without a variable, nginx will not start if upstream is down or unavailable - resolver 127.0.0.1 valid=30s; - set $upstream <%= upstreamUri %>; - proxy_ssl_verify off; - proxy_pass $upstream; - } - <% } %> - - <% if (proxyAuth.enabled) { %> # workaround caching issue after /logout. if max-age is set, browser uses cache and user thinks they have not logged out # IMPORTANT: have to keep all the add_headers at top level here to avoid repeating all the add_headers and proxy_set_headers in location block proxy_hide_header Cache-Control; @@ -416,7 +403,18 @@ server { proxy_set_header X-Remote-User $user; proxy_set_header X-Remote-Email $email; proxy_set_header X-Remote-Name $name; + + <% } else { %> + + location / { + # without a variable, nginx will not start if upstream is down or unavailable + resolver 127.0.0.1 valid=30s; + set $upstream <%= upstreamUri %>; + proxy_ssl_verify off; + proxy_pass $upstream; + } <% } %> + <% } else if ( endpoint === 'ip' ) { %> location /notfound.html { root <%= sourceDir %>/dashboard/dist;