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

@ -1,13 +1,30 @@
{
"@id": "{{ stack.name }}_upstream",
"handle": [
{
"handler": "reverse_proxy",
"upstreams": [
"@id": "{{ stack.name }}_upstream",
{% if domain is not undefined and not none %}
"match": [
{
"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"
}
]
}
]
}