Nginx – Matrix synapse with nginx reverse proxy returns 404

matrixnginx

Trying to configure Matrix synapse with Nginx ssl reverse proxy.
Here my config

server {
listen   443;
server_name domain.name.com;



ssl    on;
ssl_certificate         SSL_CERT;
ssl_certificate_key     SSL_KEY;
ssl_trusted_certificate SSL_CHAIN_CERT;


location /_matrix  {

     proxy_pass              http://127.0.0.1:8008;
     proxy_set_header        X-Forwarded-For $remote_addr;
 }

}

Configuration in homeserver.yaml (no other configuration was changed)

- port: 8008
tls: false
bind_addresses: ['::','0.0.0.0']
type: http

x_forwarded: true

When opening page at https://domain.name.com get 404 not found.
When opening http://192.168.0.10:8008/_matrix/ works.

Is it problem of Nginx or Matrix config file?

UPDATE: After I've installed the latest version of Matrix, location /_matrix work fine. Right path for nginx proxy should be /_matrix as in the manual.
This is how to check ssl https://domain,name.com/_matrix/client/versions

Best Answer

Nginx reverse proxying synapse should look something like this:

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name matrix.example.com;

        location /_matrix {
            proxy_pass http://localhost:8008;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
    }

    server {
        listen 8448 ssl default_server;
        listen [::]:8448 ssl default_server;
        server_name example.com;

        location / {
            proxy_pass http://localhost:8008;
            proxy_set_header X-Forwarded-For $remote_addr;
        }
    }

https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md

Related Topic