1. Output of caddy version
:
v2.6.1 h1:EDqo59TyYWhXQnfde93Mmv4FJfYe00dO60zMiEt+pzo=
2. How I run Caddy:
sudo docker-compose up -d
a. System environment:
Docker on Bodhi Linux
b. Command:
Paste command here.
c. Service/unit/compose file:
services:
synapse:
image: matrixdotorg/synapse:latest
container_name: synapse
restart: unless-stopped
volumes:
- ./data:/data
environment:
- SYNAPSE_SERVER_NAME=synhang.host
- SYNAPSE_REPORT_STATS=no
- VIRTUAL_HOST=synhang.ddns.net
caddy:
image: caddy:latest
container_name: synapse-caddy
restart: unless-stopped
ports:
- 80:80
- 443:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./site:/srv
- ./caddy_data:/data:rw
- ./caddy_config:/config:rw
d. My complete Caddy config:
synhang.ddns.net {
tls myemail@proton.me
file_server
handle_path /chat* {
rewrite * /_matrix/static{uri}
reverse_proxy synapse:8008
}
handle_path /_matrix* {
reverse_proxy synapse:8008
}
}
3. The problem I’m having:
I need all URLs ending in /_matrix* to redirect to the synapse container. However, I get a 404 error when doing this from my domain, even though logging directly into localhost:8008 redirects correctly. I believe the issue is that the synapse server is set to accept connections at 8008 with no trailing path in the URL (i.e. not synapse:8008/_matrix/static) and then it redirects to /_matrix/static, however these directories don’t actually exist. When I rewrite the url as /_matrix/static I believe it is requesting synapse:8008/_matrix/static which doesn’t actually exist. So how can I force this to redirect to synapse:8008. I also need all URLs include /_matrix* to redirect to synapse:8008. I also want /chat* to redirect to synapse:8008. How would I achieve this?
Also, if I why is it necessary to include the reverse_proxy directive in the chat* handle_path directive? Once it rewrites /chat* as /_matrix/static shouldn’t it then be handled by the /_matrix* handle_path and reverse proxy from there? I can only get it to work when using rewrite followed by reverse proxy.
4. Error messages and/or full log output:
Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.