smart proxy: do not redirect when given argument

?redirect=false
This commit is contained in:
Iain Learmonth 2022-08-15 10:13:44 +01:00
parent 2823033e67
commit 5db44e68e9

View file

@ -176,7 +176,7 @@ class ProxyAutomation(TerraformAutomation):
}
""" + self.sp_trusted_prefixes() + """
geoip2_proxy_recursive on;
map $geoip2_data_country_code $redirect_country {
map $geoip2_data_country_code $redirect_country {
default yes;
""" + "\n".join([f" {cc} no;" for cc in app.config['CENSORED_COUNTRIES']]) + """
}
@ -186,6 +186,12 @@ class ProxyAutomation(TerraformAutomation):
listen 443 ssl;
server_name origin-{{ origin.id }}.{{ provider }}.smart.{{ smart_zone[:-1] }};
if ($redirect_country = yes) {
set $redirect_test 1;
}
if ($arg_redirect = "false") {
set $redirect_test 0;
}
if ($redirect_test = 1) {
rewrite ^ https://{{ origin.domain_name }}$request_uri? break;
}
location / {