.well-known struggles and a work around

I found it challenging to serve up the .well-known files as part of a matrix messaging installation. Matrix is described here: Introduction | Matrix.org. These servers are federated and they discover each other using either SRV records in DNS or with well known files, for example: https://matrix.org/.well-known/matrix/server.

It took me a while to realize that the redir directive is such high priority. Like many sites I redir all traffic from to www..

I ended up with this caddy configuration for :

http://<DOMAIN>.org {
        redir https://www.<DOMAIN>.org{uri}
}

https://<DOMAIN>.org {
    route {
        reverse_proxy /.well-known/matrix/* https://matrix.<DOMAIN>.org {
            header_up Host matrix.<DOMAIN>.org
        }
        redir https://www.<DOMAIN>.org{uri}
    }
}

I failed to puzzle out how to do this with the simplified config file.

Maybe this will be helpful for others.

But, I’m curious if my solution can be improved?

Yeah, you pretty much have the simplest way to do it.

This article should answer some of your remaining questions:

1 Like

It’s funny how every easy to use DSL ends up with an appendix in the doc ike that. Been there!

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.