spantaleev / matrix-docker-ansible-deploy

🐳 Matrix (An open network for secure, decentralized communication) server setup using Ansible and Docker
GNU Affero General Public License v3.0
4.88k stars 1.04k forks source link

500 internal server error on nginx #1134

Closed ethindp closed 3 years ago

ethindp commented 3 years ago

My nginx server is giving me a 500 error whenever I attempt to access the-gdn.net/.well-known/matrix/(client|server). Its configured (the domain anyway) like so:

server {
    listen                  443 ssl http2;
    listen                  443 http3 reuseport;
    listen                  [::]:443 ssl http2;
    listen                  [::]:443 http3 reuseport;
    server_name             the-gdn.net;
    root                    /var/www/the-gdn.net/;

    # SSL
    ssl_certificate         /etc/letsencrypt/live/the-gdn.net/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/the-gdn.net/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/the-gdn.net/chain.pem;

    # security
    include                 nginxconfig.io/security.conf;

    # restrict methods
    if ($request_method !~ ^(GET|POST|PUT|PATCH|DELETE|HEAD|CONNECT|OPTIONS)$) {
        return '400';
    }

    # index.php
    index index.php;

    # index.html fallback
    location / {
        try_files $uri $uri/ /index.html;
    }

    # index.php fallback
    location ~ ^/api/ {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location /.well-known/matrix {
        proxy_pass https://matrix.the-gdn.net/.well-known/matrix;
        proxy_set_header X-Forwarded-For $remote_addr;
    }

    # additional config
    include nginxconfig.io/general.conf;
}

# HTTP redirect
server {
    listen      80;
    listen      [::]:80;
    server_name the-gdn.net;
    include     nginxconfig.io/letsencrypt.conf;

    location / {
        return 301 https://the-gdn.net$request_uri;
    }
}

What am I doing wrong? Going to the matrix subdomain works fine with URLs for .well-known, just not the base.

spantaleev commented 3 years ago

Where's the base domain hosted? On the same server?

Are you using the integrated nginx webserver (matrix-nginx-proxy) or something else?

You may get quicker and better help in our support room

ethindp commented 3 years ago

Everything works now. My root nginx server was using the "modern" TLS configuration so I had to set the proxy config to also use that configuration.