1. Caddy version (caddy version
):
2.3.0
2. How I run Caddy:
Caddy-docker-proxy
a. System environment:
Caddy-docker-proxy via docker-compose on host Ubuntu Budgie 20.10.
b. Command:
Not aware. caddy-docker-proxy takes care of everything.
c. Service/unit/compose file:
services:
firefox:
(...)
labels:
caddy_1: $DOMAIN
caddy_1.handle_path: /firefoxsync*
caddy_1.handle_path.reverse_proxy: "{{upstreams 5000}}"
caddy_1.tls: $EMAIL
bitwarden:
(...)
labels:
caddy_2: $DOMAIN
caddy_2.handle_path: /bitwarden*
caddy_2.handle_path.reverse_proxy: "{{upstreams 80}}"
# caddy2.handle_path.reverse_proxy_2: "/notifications/hub/negotiate {{upstreams 80}}"
# caddy2.handle_path.reverse_proxy_3: "/notifications/hub {{upstreams 3012}}"
caddy_2.tls: $EMAIL
caddy_2.encode: gzip
caddy_2.header.X-XSS-Protection: '"1; mode=block;"'
caddy_2.header.X-Frame-Options: "DENY"
caddy_2.header.X-Content-Type-Options: "none"
syncthing:
(...)
labels:
caddy_3: $DOMAIN
caddy_3.handle_path: /syncthing*
caddy_3.handle_path.reverse_proxy: "{{upstreams 8384}}"
caddy_3.tls: $EMAIL
onlyoffice:
(...)
labels:
caddy_5: $DOMAIN
caddy_5.handle_path: /office*
caddy_5.handle_path.reverse_proxy: "{{upstreams 80}}"
caddy_5.tls: $EMAIL
caddy_5.file_server: ""
caddy_5.encode: gzip
caddy_5.header.X-Content-Type-Options: "nosniff"
d. My complete Caddyfile or JSON config:
mydomain.tld {
handle_path /bitwarden* {
encode gzip
header {
X-Content-Type-Options none
X-Frame-Options DENY
X-XSS-Protection "1; mode=block;"
}
reverse_proxy 172.26.0.3:80
}
handle_path /firefoxsync* {
reverse_proxy 172.26.0.4:5000
}
handle_path /office* {
encode gzip
file_server
header {
X-Content-Type-Options nosniff
}
reverse_proxy 172.26.0.6:80
}
handle_path /syncthing* {
reverse_proxy 172.26.0.5:8384
}
tls mydomain@mydomain.tld
}
3. The problem I’m having:
I am trying to switch from subdomains to subfolders to access my services. I have 2 problems:
- Even with
syncthing*
a slash at the endsyncthing/
is still required to load the page properly otherwise it looks like a text-only site. This is not the case for bitwarden, it works without slash at the end. - The admin page of bitwarden (normally accessible via
subdomain.domain.com/admin
) at mydomain.tld/bitwarden/admin is text-only even with a slash at the end. - Onlyoffice normally redirects to
subdomain.domain.com/welcome
now with this subfolder config it does the same! so nothing loads. It does work when I manually go todomain.tld/office/welcome
4. Error messages and/or full log output:
no errors.
5. What I already tried:
Lot’s of things as the dev of caddy-docker-proxy really helped me get it working up until this point.
Since I am so close now, I am reluctant to switch back to subdomains.
I have started to believe subfolders are more secure by obscurity: subdomains are publicly known, by DNS servers etc. By using subfolders, someone needs to know the subfolder name to access it.
6. Links to relevant resources:
The "subfolder problem", OR, "why can't I reverse proxy my app into a subfolder?"
Unfortunately, it is like a blog article, it does not really explain how to do it, with examples etc.