smart_proxy: add asset domains concept

This commit is contained in:
Iain Learmonth 2022-05-25 15:32:17 +01:00
parent dfb4d66557
commit d99cf88f38
6 changed files with 60 additions and 4 deletions

View file

@ -167,7 +167,7 @@ class ProxyAutomation(TerraformAutomation):
{% for origin in origins %}
server {
listen 443 ssl;
server_name origin-{{ origin.id }}.{{ provider }}.smart.censorship.guide;
server_name origin-{{ origin.id }}.{{ provider }}.smart.{{ smart_zone[:-1] }};
location / {
proxy_set_header Accept-Encoding "";
proxy_ssl_server_name on;
@ -175,6 +175,13 @@ class ProxyAutomation(TerraformAutomation):
subs_filter_types text/html text/css text/xml;
subs_filter https://{{ origin.domain_name }}/ /;
subs_filter "\\\"https://{{ origin.domain_name }}\\\"" /;
{% for asset_origin in origin.group.origins | selectattr("origin", "true") %}
{% for asset_proxy in asset_origin.proxies | selectattr("provider", provider) %}
{% if loop.first %}
subs_filter https://{{ asset_origin.domain_name }}/ {{ asset_proxy.url }}/
{% endif %}
{% endfor %}
{% endfor %}
}
ssl_certificate /etc/ssl/smart_proxy.crt;
ssl_certificate_key /etc/ssl/private/smart_proxy.key;
@ -182,4 +189,5 @@ class ProxyAutomation(TerraformAutomation):
{% endfor %}
""",
provider=self.provider,
origins=group_origins)
origins=group_origins,
smart_zone=app.config['SMART_ZONE'])

View file

@ -122,7 +122,7 @@ class ProxyCloudfrontAutomation(ProxyAutomation):
{% for proxy in proxies %}
module "cloudfront_{{ proxy.id }}" {
source = "sr2c/bc-proxy/aws"
version = "0.0.7"
version = "0.0.10"
{% if proxy.origin.smart %}
origin_domain = "origin-{{ proxy.origin.id }}.cloudfront.smart.{{ smart_zone[:-1] }}"
{% else %}