Add conditional default subdomain setting to proxy

If a domain has been declared for the host, the upstream file will proxy
at a subdomain named for the stack it proxies to,
otherwise it will do the same for the path.
This commit is contained in:
Marty Oehme 2021-07-30 11:50:10 +02:00
parent 03a0b0ce00
commit daef2b7f13
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 26 additions and 10 deletions

View file

@ -5,4 +5,3 @@ docker_swarm_advertise_addr: eth1
caddy_use_debug: yes caddy_use_debug: yes
caddy_use_https: no caddy_use_https: no
caddy_tls_use_staging: yes caddy_tls_use_staging: yes
caddy_create_test_file_server: yes

View file

@ -1,13 +1,30 @@
{ {
"@id": "{{ stack.name }}_upstream", "@id": "{{ stack.name }}_upstream",
"handle": [ {% if domain is not undefined and not none %}
{ "match": [
"handler": "reverse_proxy",
"upstreams": [
{ {
"dial": "{{ stack.name }}_app:80" "host": [
"{{ stack.name }}.{{ domain }}"
]
} }
] ],
} {% else %}
] "match": [
{
"path": [
"/{{ stack.name }}*"
]
}
],
{% endif %}
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
{
"dial": "{{ stack.name }}_app:80"
}
]
}
]
} }