1. Caddy version (caddy version
):
v2.3.0
2. How I run Caddy:
I’m running Caddy as a addon on my local Home Assistant installation. This was provided here: https://github.com/einschmidt/hassio-addons
So far I have it up and running, a certificate was created as well for my DDNS Domain (.home-webserver.de). All verified and valid.
a. System environment:
Home Assistant 2021.2.1 in which Caddy runs as an addon (which utilizes Docker where it actually runs in)
b. Command:
Can’t tell but it will use a Caddyfile so presumingly it runs at least with that flag. Since it all starts up nicely I did not dig deeper here.
c. Service/unit/compose file:
don't have one, it's a HA addon
d. My complete Caddyfile or JSON config:
Did test various combinations how things might work, however none really did.
{
email <my email>
}
<name>.home-webserver.de {
route /qnap/* { # QNAP NAS
uri strip_prefix /qnap
reverse_proxy /qnap/* 10.0.0.10:8088
}
route /unifi/* { # QNAP Unifi Controller
uri strip_prefix /unifi
reverse_proxy {
to 10.0.0.10:38193
transport http {
tls_insecure_skip_verify
}
}
}
route /homeassistant/* { # Home Assistant
uri strip_prefix /homeassistant
reverse_proxy 10.0.0.20:8123
}
route /grocy/* { # HA Grocy
uri strip_prefix /grocy
reverse_proxy 10.0.0.20:8080
}
route /barcodebuddy/* { # HA Barcode Buddy for Grocy
uri strip_prefix /barcodebuddy
reverse_proxy 10.0.0.20:8621
}
}
Other config I checked based on sources online:
{
email <my email>
}
# <name>.home-webserver.de
# reverse_proxy /qnap/* takekinas.foeller:8088
# reverse_proxy /unifi/* takekinas.foeller:38193
# reverse_proxy /homeassistant/* homeassistant.foeller:8123
# reverse_proxy /grocy/* homeassistant.foeller:8080
# reverse_proxy /barcodebuddy/* homeassistant.foeller:8621
3. The problem I’m having:
I want to use subdirectories to reverse proxy from my external domain to various services in my local network (eg. https://.home-webserver.de/homeassistant points to my Home Assistant install (aka localhost since Caddy runs on the same machine) while https://.home-webserver.de/qnap points to my NAS which is a different device in my local network.
So far I was only able to get one service (QNAP) running from the TLD but not from any subdirectory path. Whenever I do this for any service all I am getting is a white page.
Also only qnap was able to be used as a target for my TLD. When using it with home assistant I even got a white page there no matter what I did.
I’ve spend 2 days now checking every config I found on the internet so far. I checked if route
is the right thing to use, also checked with handle_path
instead of it but so far I was not able to get Caddy up and running.
Since it is known for an easy configuration and also handles the certificate the same time, I really would love to use it as my reverse proxy but at the present moment I do not know how to archive what I need it running like. I checked the docs and went back and forth but 2 full days are now gone and I am not close to have it running as needed. So I’m completely lost here and perhaps somebody here can give me a jump start since I obviously cannot see (and perhaps understand) what I am doing wrong.
4. Error messages and/or full log output:
This is the complete output of the HA addon log. I removed the domain matching to the above since this I am sure it not the cause of my struggling.
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] scripts: applying...
[fix-attrs.d] scripts: exited 0.
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 00-banner.sh: executing...
-----------------------------------------------------------
Add-on: Caddy 2
Open source web and proxy server with automatic HTTPS
-----------------------------------------------------------
Add-on version: 0.2.1
You are running the latest version of this add-on.
System: Home Assistant OS 5.10 (amd64 / intel-nuc)
Home Assistant Core: 2021.2.1
Home Assistant Supervisor: 2021.01.7
-----------------------------------------------------------
Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
[cont-init.d] 00-banner.sh: exited 0.
[cont-init.d] 01-log-level.sh: executing...
Log level is set to INFO
[cont-init.d] 01-log-level.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
INFO: Starting Caddy...
INFO: Use built-in Caddy
v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=
INFO: Caddyfile found at /config/Caddyfile
{"level":"info","ts":1612779194.0362265,"msg":"using provided configuration","config_file":"/config/Caddyfile","config_adapter":""}
{"level":"info","ts":1612779194.0622973,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["127.0.0.1:2019","localhost:2019","[::1]:2019"]}
{"level":"info","ts":1612779194.0641813,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
{"level":"info","ts":1612779194.0734541,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1612779194.0652502,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc0002920e0"}
{"level":"info","ts":1612779194.089678,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["<name>.home-webserver.de"]}
{"level":"info","ts":1612779194.092427,"logger":"tls","msg":"cleaned up storage units"}
{"level":"info","ts":1612779194.1406207,"msg":"autosaved config","file":"/data/caddy/autosave.json"}
{"level":"info","ts":1612779194.1434288,"msg":"serving initial configuration"}
5. What I already tried:
Various attempts with different combinations of all configs I found. I searched the forums here and at home assistant for possible solutions. Most however covered Caddy v1 so I figured that out and checked how I can migrate this to v2. Did that and checked many google search results. So far I was not successful other than getting Caddy to deliver my QNAP to the TLD but not to any subdomain. Consulted a friend if he has an idea, so he installed Caddy on his HA installation but could not find the missing piece of the puzzle either. So after 2 days I choose to post this in both forums, here and in the HA one. Got not reply at the Home Assistant forum yet, so I checked other ideas this morning but still, no luck.
6. Links to relevant resources:
and many more, but as a new user I cannot post more links…