One of the prerequisites for installing Matrix server is proper .well-known setup. This is important not only for Matrix client apps and servers, but also for server admin panel, in-app calls, and other features.
Here we collect configuration examples for various web servers and platforms to help you set up the necessary redirects.
If you don’t see your web server or platform listed here, please contact us for assistance!
Web Servers¶
Nginx¶
# This is your HTTPS-enabled server for your-server.com.
# Replace your-server.com with your Matrix server's base/apex domain.
server {
server_name your-server.com;
location ^~ /.well-known/matrix/ {
add_header Access-Control-Allow-Origin "*" always;
return 301 https://matrix.your-server.com$request_uri;
}
# other configuration
}
Apache2¶
# This is your HTTPS-enabled server for your-server.com.
# Replace your-server.com with your Matrix server's base/apex domain.
<VirtualHost *:443>
ServerName your-server.com
# Ensure mod_headers and mod_alias (or mod_rewrite) are enabled
<Location "/.well-known/matrix/">
Header always set Access-Control-Allow-Origin "*"
</Location>
RedirectMatch 301 ^/\.well-known/matrix/(.*)$ https://matrix.your-server.com/.well-known/matrix/$1
# other configuration
</VirtualHost>
Caddy 2¶
# This is your HTTPS-enabled frontend for your-server.com.
# Replace your-server.com with your Matrix server's base/apex domain.
your-server.com {
@matrixWellKnown path /.well-known/matrix/*
header @matrixWellKnown Access-Control-Allow-Origin "*"
redir @matrixWellKnown https://matrix.your-server.com{uri} 301
# other configuration
}
Platforms¶
Vercel¶
Configured in vercel.json, replace your-server.com with your Matrix server base/apex domain:
{
"headers": [
{
"source": "/.well-known/matrix/(.*)",
"headers": [
{
"key": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
],
"redirects": [
{
"source": "/.well-known/matrix/server",
"destination": "https://matrix.your-server.com/.well-known/matrix/server",
"statusCode": 301
},
{
"source": "/.well-known/matrix/client",
"destination": "https://matrix.your-server.com/.well-known/matrix/client",
"statusCode": 301
},
{
"source": "/.well-known/matrix/support",
"destination": "https://matrix.your-server.com/.well-known/matrix/support",
"statusCode": 301
}
]
}