Commit c59f2588 authored by Łukasz Nowak's avatar Łukasz Nowak

caddy-frontend: Support missing url

If url is missing, the generated files shall be correct.
parent cd779a2a
......@@ -55,7 +55,7 @@ md5sum = 4dbb8560e4de1af2a0706b020e713fe7
[template-default-slave-virtualhost]
filename = templates/default-virtualhost.conf.in
md5sum = 8a0b6c937384c299dd36274c9fa8d104
md5sum = 07b3a9a0f25d1a173066a39293f09cd6
[template-cached-slave-virtualhost]
filename = templates/cached-virtualhost.conf.in
......
......@@ -9,6 +9,7 @@
{%- set https_only = ('' ~ slave_parameter.get('https-only', '')).lower() in TRUE_VALUES -%}
{%- set slave_type = slave_parameter.get('type', '') -%}
{%- set host_list = [slave_parameter.get('custom_domain')] + server_alias_list -%}
{%- set backend_url = slave_parameter.get('https-url', slave_parameter.get('url', '')) %}
{%- set http_host_list = [] %}
{%- set https_host_list = [] %}
{%- for host in host_list %}
......@@ -55,8 +56,8 @@
# TODO-Caddy RequestHeader edit Accept-Encoding "(^gzip,.*|.*, gzip,.*|.*, gzip$|^gzip$)" "gzip"
{% endif %}
{% if slave_type == 'zope' -%}
proxy / {{ slave_parameter.get('https-url', slave_parameter.get('url', '')) }} {
{% if slave_type == 'zope' and backend_url -%}
proxy / {{ backend_url }} {
transparent
timeout 600s
{%- if ssl_proxy_verify %}
......@@ -78,9 +79,9 @@
regexp (.*)
to /VirtualHostBase/{scheme}%2F%2F{hostonly}:{{ slave_parameter.get('virtualhostroot-https-port', '443') }}%2F{{ slave_parameter.get('path', '') }}%2FVirtualHostRoot/{1}
}
{% elif slave_type == 'redirect' -%}
{% elif slave_type == 'redirect' and backend_url -%}
redir 302 {
/ {{ slave_parameter.get('https-url', slave_parameter.get('url', ''))}}{uri}
/ {{ backend_url}}{uri}
}
{% else -%}
{% if 'default-path' in slave_parameter %}
......@@ -89,7 +90,8 @@
/ {scheme}://{host}/{{ slave_parameter.get('default-path') }}
}
{% endif -%}
proxy / {{ slave_parameter.get('https-url', slave_parameter.get('url', '')) }} {
{%- if backend_url %}
proxy / {{ backend_url }} {
transparent
timeout 600s
{%- if ssl_proxy_verify %}
......@@ -101,6 +103,7 @@
insecure_skip_verify
{%- endif %}
}
{%- endif %}
{% endif -%}
}
......@@ -136,12 +139,12 @@
{%- if https_only %}
redir / https://{host}{uri}
{% elif slave_type == 'redirect' -%}
{% elif slave_type == 'redirect' and backend_url -%}
redir 302 {
/ {{ slave_parameter.get('https-url', slave_parameter.get('url', ''))}}{uri}
/ {{ backend_url }}{uri}
}
{% elif slave_type == 'zope' -%}
proxy / {{ slave_parameter.get('https-url', slave_parameter.get('url', '')) }} {
{% elif slave_type == 'zope' and backend_url -%}
proxy / {{ backend_url }} {
transparent
timeout 600s
{%- if ssl_proxy_verify %}
......@@ -170,6 +173,7 @@
/ {scheme}://{host}/{{ slave_parameter.get('default-path') }}
}
{% endif -%}
{%- if slave_parameter.get('url', '') %}
proxy / {{ slave_parameter.get('url', '') }} {
transparent
timeout 600s
......@@ -182,6 +186,7 @@
insecure_skip_verify
{%- endif %}
}
{% endif -%}
{% endif -%}
# If nothing exist : put a nice error
# ErrorDocument 404 /notfound.html
......
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