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

caddy-frontend: Support missing url

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