From 1b61d7a641ae1194ac92f706e10154bd1d13fbdf Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Sun, 31 Mar 2024 13:55:50 +0100 Subject: [PATCH] Refactor Nginx configuration to handle billing redirection*** --- Nginx/default.conf.template | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/Nginx/default.conf.template b/Nginx/default.conf.template index 189b3f6d7e..1e8b01faba 100644 --- a/Nginx/default.conf.template +++ b/Nginx/default.conf.template @@ -127,21 +127,34 @@ server { location / { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + if ($billing_enabled = true) { + return 301 https://$host$request_uri; + } - proxy_pass http://status-page; + if ($billing_enabled != true) { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_pass http://status-page; + } + } location /status-page { - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + if ($billing_enabled = true) { + return 301 https://$host$request_uri; + } - proxy_pass http://status-page; + if ($billing_enabled != true) { + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_pass http://status-page; + } } location /status-page-api/ {