diff --git a/app/terraform/proxy/__init__.py b/app/terraform/proxy/__init__.py index 2f8f466..d1234ff 100644 --- a/app/terraform/proxy/__init__.py +++ b/app/terraform/proxy/__init__.py @@ -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 / {