One of the prerequisites for installing Matrix server is proper .well-known setup. This is important for both federation and client apps connectivity.
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 {
        rewrite ^/(.*)$ https://matrix.your-server.com/$1 permanent;
	}
	# 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
    Redirect 301 /.well-known/matrix https://matrix.your-server.com/.well-known/matrix
	# 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 {
    redir /.well-known/matrix/* https://matrix.your-server.com{uri} permanent
	# other configuration
}
Platforms¶
Vercel¶
Configured in vercel.json, replace your-server.com with your Matrix server base/apex domain:
{
  "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
    }
  ]
}