Commit 0b81971c authored by Łukasz Nowak's avatar Łukasz Nowak

rapid-cdn: c->h: Implement type:redirect

parent 462f5262
...@@ -38,7 +38,7 @@ md5sum = cba4d995962f7fbeae3f61c9372c4181 ...@@ -38,7 +38,7 @@ md5sum = cba4d995962f7fbeae3f61c9372c4181
[template-frontend-haproxy-configuration] [template-frontend-haproxy-configuration]
_update_hash_filename_ = templates/frontend-haproxy.cfg.in _update_hash_filename_ = templates/frontend-haproxy.cfg.in
md5sum = b1cd67d96cce91b5173ce09a9fdc2ac8 md5sum = 3c4ddc00f6dc609ec830648d1f394b81
[template-frontend-haproxy-crt-list] [template-frontend-haproxy-crt-list]
_update_hash_filename_ = templates/frontend-haproxy-crt-list.in _update_hash_filename_ = templates/frontend-haproxy-crt-list.in
......
...@@ -123,13 +123,6 @@ ...@@ -123,13 +123,6 @@
{%- endif %} {%- endif %}
} {# rewrite #} } {# rewrite #}
{%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #} {%- endif %} {#- if slave_parameter['prefer-gzip-encoding-to-backend'] #}
{%- elif slave_parameter['type'] == 'redirect' %}
{%- if backend_url %}
# Redirect configuration
redir 302 {
/ {{ backend_url }}{rewrite_uri}
}
{%- endif %}
{%- elif slave_parameter['type'] == 'notebook' %} {%- elif slave_parameter['type'] == 'notebook' %}
proxy / {{ backend_url }} { proxy / {{ backend_url }} {
{{ proxy_header() }} {{ proxy_header() }}
......
...@@ -93,37 +93,41 @@ backend {{ slave_instance['slave_reference'] }}-{{ scheme }} ...@@ -93,37 +93,41 @@ backend {{ slave_instance['slave_reference'] }}-{{ scheme }}
redirect scheme https code 302 redirect scheme https code 302
{%- else %} {%- else %}
{%- if 'hostname' in info_dict and 'port' in info_dict %} {%- if 'hostname' in info_dict and 'port' in info_dict %}
{%- if slave_instance['type'] == 'redirect' %}
redirect prefix {{ info_dict['scheme'] }}://{{ info_dict['hostname'] }}:{{ info_dict['port'] }} code 302
{%- else %}
server {{ slave_instance['slave_reference'] }}-backend-{{ scheme }} {{ info_dict['hostname'] }}:{{ info_dict['port'] }} server {{ slave_instance['slave_reference'] }}-backend-{{ scheme }} {{ info_dict['hostname'] }}:{{ info_dict['port'] }}
{%- if slave_instance['disable-via-header'] %} {%- if slave_instance['disable-via-header'] %}
http-response del-header Via http-response del-header Via
{%- else %} {%- else %}
http-response add-header Via "%HV rapid-cdn-frontend-{{ configuration['node-id'] }}-{{ configuration['version-hash'] }}" http-response add-header Via "%HV rapid-cdn-frontend-{{ configuration['node-id'] }}-{{ configuration['version-hash'] }}"
{%- endif %} {%- endif %}
{%- if scheme == 'https' %} {%- if scheme == 'https' %}
{%- if slave_instance['strict-transport-security'] > 0 %} {%- if slave_instance['strict-transport-security'] > 0 %}
{%- set strict_transport_security = ['max-age=%i' % (slave_instance['strict-transport-security'],)] %} {%- set strict_transport_security = ['max-age=%i' % (slave_instance['strict-transport-security'],)] %}
{%- if slave_instance['strict-transport-security-sub-domains'] %} {%- if slave_instance['strict-transport-security-sub-domains'] %}
{%- do strict_transport_security.append('; includeSubDomains') %} {%- do strict_transport_security.append('; includeSubDomains') %}
{%- endif %} {%- endif %}
{%- if slave_instance['strict-transport-security-preload'] %} {%- if slave_instance['strict-transport-security-preload'] %}
{%- do strict_transport_security.append('; preload') %} {%- do strict_transport_security.append('; preload') %}
{%- endif %} {%- endif %}
http-response set-header Strict-Transport-Security "{{ ''.join(strict_transport_security) }}" http-response set-header Strict-Transport-Security "{{ ''.join(strict_transport_security) }}"
{%- endif %}
{%- endif %} {%- endif %}
{%- endif %} {%- for disabled_cookie in slave_instance['disabled-cookie-list'] %}
{%- for disabled_cookie in slave_instance['disabled-cookie-list'] %}
http-request replace-header Cookie (.*)(^{{ disabled_cookie | replace('%', '%%') }}=[^;]*;\ |;\ {{ disabled_cookie }}=[^;]*|^{{ disabled_cookie }}=[^;]*$)(.*) \1\3 http-request replace-header Cookie (.*)(^{{ disabled_cookie | replace('%', '%%') }}=[^;]*;\ |;\ {{ disabled_cookie }}=[^;]*|^{{ disabled_cookie }}=[^;]*$)(.*) \1\3
{%- endfor %} {%- endfor %}
{%- if slave_instance['disable-no-cache-request'] %} {%- if slave_instance['disable-no-cache-request'] %}
http-request del-header Cache-Control http-request del-header Cache-Control
http-request del-header Pragma http-request del-header Pragma
{%- endif %} {%- endif %}
{%- if slave_instance['prefer-gzip-encoding-to-backend'] %} {%- if slave_instance['prefer-gzip-encoding-to-backend'] %}
http-request set-header Accept-Encoding gzip if { hdr(Accept-Encoding) -m sub gzip } http-request set-header Accept-Encoding gzip if { hdr(Accept-Encoding) -m sub gzip }
{%- endif %} {%- endif %}
{%- if info_dict['path'] %} {%- if info_dict['path'] %}
http-request set-path {{ info_dict['path'] }}%[path] http-request set-path {{ info_dict['path'] }}%[path]
{%- endif %} {# if info_dict['path'] #} {%- endif %} {# if info_dict['path'] #}
{%- endif %} {# if slave_instance['type'] == 'redirect' #}
{%- endif %} {# if 'hostname' in info_dict and 'port' in info_dict #} {%- endif %} {# if 'hostname' in info_dict and 'port' in info_dict #}
{%- endif %} {# if scheme == 'http' and slave_instance['https-only'] #} {%- endif %} {# if scheme == 'http' and slave_instance['https-only'] #}
{%- endfor %} {# for (scheme, prefix) in SCHEME_PREFIX_MAPPING.items() #} {%- endfor %} {# for (scheme, prefix) in SCHEME_PREFIX_MAPPING.items() #}
......
...@@ -2391,6 +2391,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin): ...@@ -2391,6 +2391,7 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
headers = self.assertResponseHeaders( headers = self.assertResponseHeaders(
result_http, via=False, backend_reached=False) result_http, via=False, backend_reached=False)
self.assertEqual( self.assertEqual(
'https://url.example.com:%s/test-path/deeper' % (HTTP_PORT,), 'https://url.example.com:%s/test-path/deeper' % (HTTP_PORT,),
headers['Location'] headers['Location']
...@@ -3530,6 +3531,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin): ...@@ -3530,6 +3531,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
result.headers['Location'] result.headers['Location']
) )
headers = self.assertResponseHeaders(
result, via=False, backend_reached=False)
result = fakeHTTPResult( result = fakeHTTPResult(
parameter_dict['domain'], parameter_dict['domain'],
'test-path/deep/.././deeper') 'test-path/deep/.././deeper')
...@@ -3544,6 +3548,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin): ...@@ -3544,6 +3548,9 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
result.headers['Location'] result.headers['Location']
) )
headers = self.assertResponseHeaders(
result, via=False, backend_reached=False)
def test_type_redirect_custom_domain(self): def test_type_redirect_custom_domain(self):
parameter_dict = self.assertSlaveBase( parameter_dict = self.assertSlaveBase(
'type-redirect-custom_domain', hostname='customdomaintyperedirect') 'type-redirect-custom_domain', hostname='customdomaintyperedirect')
...@@ -3566,6 +3573,10 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin): ...@@ -3566,6 +3573,10 @@ class TestSlave(SlaveHttpFrontendTestCase, TestDataMixin, AtsMixin):
result.headers['Location'] result.headers['Location']
) )
headers = self.assertResponseHeaders(
result, via=False, backend_reached=False)
def test_ssl_proxy_verify_ssl_proxy_ca_crt_unverified(self): def test_ssl_proxy_verify_ssl_proxy_ca_crt_unverified(self):
parameter_dict = self.assertSlaveBase( parameter_dict = self.assertSlaveBase(
'ssl-proxy-verify_ssl_proxy_ca_crt-unverified') 'ssl-proxy-verify_ssl_proxy_ca_crt-unverified')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment