Matrix Synapse Admin Failed to fetch fix (via Caddy V2)
Infrastructure: Matrix Synapse admin UI through Caddy V2 reverse proxy via docker compose.
For easier administration of my Matrix Synapse I choose to run https://github.com/etkecc/synapse-admin via docker compose. Unfortunately I was getting CORS error after logging. Though I followed official Matrix Synapse guide for Caddy V2 reverse proxy this did not work.
I had to add last line as shown in code snippet below to Caddyfile to make Synapse Admin work. Also notice how I build the blocks using route so lines are executed one after another - not load balanced as in original guide.
example.com {
route {
header /.well-known/matrix/* Content-Type application/json
header /.well-known/matrix/* Access-Control-Allow-Origin *
respond /.well-known/matrix/server `{"m.server": "matrix.example.com:443"}`
respond /.well-known/matrix/client `{"m.homeserver":{"base_url":"https://matrix.example.com"},"m.identity_server":{"base_url":"https://identity.example.com"}}`
reverse_proxy my_blog_you_dont_want_to_see:1234
}
}
matrix.example.com {
route {
reverse_proxy /_matrix/* localhost:8008
reverse_proxy /_synapse/client/* localhost:8008
reverse_proxy localhost:8008 #<<<<< THIS FIXED THE ISSUE
}
}
```Do not forget to reload Caddy V2 after update of Caddyfile. For me it is:
lipown@lipowndocker:/$ docker exec -w /etc/caddy caddy caddy fmt --overwrite
lipown@lipowndocker:/$ docker exec -w /etc/caddy caddy caddy reload