Commit c8ef7db5 authored by Łukasz Nowak's avatar Łukasz Nowak Committed by Łukasz Nowak

Feature/caddy frontend path normalization

/reviewed-on !487
parent dddb4d20
...@@ -58,7 +58,7 @@ md5sum = f20d6c3d2d94fb685f8d26dfca1e822b ...@@ -58,7 +58,7 @@ md5sum = f20d6c3d2d94fb685f8d26dfca1e822b
[template-default-slave-virtualhost] [template-default-slave-virtualhost]
filename = templates/default-virtualhost.conf.in filename = templates/default-virtualhost.conf.in
md5sum = e21bf673c35f049e7457ec78de9a1964 md5sum = 55d0ca695318d7d6111742f4b37fe1b8
[template-cached-slave-virtualhost] [template-cached-slave-virtualhost]
filename = templates/cached-virtualhost.conf.in filename = templates/cached-virtualhost.conf.in
......
...@@ -42,12 +42,25 @@ ...@@ -42,12 +42,25 @@
log / {{ slave_parameter.get('access_log') }} "{remote} {>REMOTE_USER} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\" {latency_ms}" log / {{ slave_parameter.get('access_log') }} "{remote} {>REMOTE_USER} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\" {latency_ms}"
errors {{ slave_parameter.get('error_log') }} errors {{ slave_parameter.get('error_log') }}
{%- if prefer_gzip and not (slave_type == 'zope' and backend_url) %} {%- if not (slave_type == 'zope' and backend_url) %}
{% if prefer_gzip %}
rewrite { rewrite {
regexp (.*)
if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)" if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
to /prefer-gzip{uri} to /prefer-gzip{1}
}
rewrite {
regexp (.*)
if {>Accept-Encoding} not_match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
to {1}
} }
{%- endif %} {#- if prefer_gzip and not (slave_type == 'zope' and backend_url) #} {% else %}
rewrite {
regexp (.*)
to {1}
}
{% endif %}
{%- endif %} {#- if not (slave_type == 'zope' and backend_url) #}
{%- if slave_type == 'zope' and backend_url %} {%- if slave_type == 'zope' and backend_url %}
# Zope configuration # Zope configuration
...@@ -105,7 +118,7 @@ ...@@ -105,7 +118,7 @@
{%- elif slave_type == 'redirect' and backend_url %} {#- if slave_type == 'zope' and backend_url #} {%- elif slave_type == 'redirect' and backend_url %} {#- if slave_type == 'zope' and backend_url #}
# Redirect configuration # Redirect configuration
redir 302 { redir 302 {
/ {{ backend_url }}{uri} / {{ backend_url }}{rewrite_uri}
} {# redir #} } {# redir #}
{%- else %} {#- if slave_type == 'zope' and backend_url #} {%- else %} {#- if slave_type == 'zope' and backend_url #}
# Default configuration # Default configuration
...@@ -163,20 +176,33 @@ ...@@ -163,20 +176,33 @@
log / {{ slave_parameter.get('access_log') }} "{remote} {>REMOTE_USER} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\" {latency_ms}" log / {{ slave_parameter.get('access_log') }} "{remote} {>REMOTE_USER} [{when}] \"{method} {uri} {proto}\" {status} {size} \"{>Referer}\" \"{>User-Agent}\" {latency_ms}"
errors {{ slave_parameter.get('error_log') }} errors {{ slave_parameter.get('error_log') }}
{%- if prefer_gzip and not (slave_type == 'zope' and backend_url) %} {%- if not (slave_type == 'zope' and backend_url) %}
{%- if prefer_gzip %}
rewrite { rewrite {
regexp (.*)
if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)" if {>Accept-Encoding} match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
to /prefer-gzip{uri} to /prefer-gzip{1}
}
rewrite {
regexp (.*)
if {>Accept-Encoding} not_match "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)"
to {1}
}
{% else %}
rewrite {
regexp (.*)
to {1}
} }
{%- endif %} {#- if prefer_gzip and not (slave_type == 'zope' and backend_url) #} {% endif %}
{%- endif %} {#- if not (slave_type == 'zope' and backend_url) #}
{%- if https_only %} {%- if https_only %}
# Enforced redirection to SSL-enabled host # Enforced redirection to SSL-enabled host
redir / https://{host}{uri} redir / https://{host}{rewrite_uri}
{%- elif slave_type == 'redirect' and slave_parameter.get('url', '') %} {#- if https_only #} {%- elif slave_type == 'redirect' and slave_parameter.get('url', '') %} {#- if https_only #}
# Redirect configuration # Redirect configuration
redir 302 { redir 302 {
/ {{ slave_parameter.get('url', '') }}{uri} / {{ slave_parameter.get('url', '') }}{rewrite_uri}
} {# redir #} } {# redir #}
{%- elif slave_type == 'zope' and backend_url %} {#- if https_only #} {%- elif slave_type == 'zope' and backend_url %} {#- if https_only #}
# Zope configuration # Zope configuration
......
This diff is collapsed.
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