Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to federate matrix synapse using NPM #1893

Closed
minnixtx opened this issue Feb 26, 2022 · 17 comments
Closed

Unable to federate matrix synapse using NPM #1893

minnixtx opened this issue Feb 26, 2022 · 17 comments
Labels

Comments

@minnixtx
Copy link

Checklist

  • Have you pulled and found the error with jc21/nginx-proxy-manager:latest docker image?
    • Yes
  • Are you sure you're not using someone else's docker image?
    • Yes
  • Have you searched for similar issues (both open and closed)?
    • Yes

Describe the bug
Would I consider this a bug? I'm not sure but I have searched everywhere else, including posting on reddit, and am unable to find an answer so this is my last resort. If this is the wrong place I apologize.

A few details, I am using a subdomain, matrix.minnix.dev, for the actual matrix server and my homeserver.yaml lists my parent domain as minnix.dev so that my user name looks like minnix@minnix.dev within matrix instead of minnix@matrix.minnix.dev. I had a configuration working quite well just using plain nginx as a reverse proxy in front of my matrix server. I actually wrote a guide about the process here. I can't get NPM to do the same thing though as I am failing the federation test here. My self-hosted matrix rooms are still available to other users and they can communicate with each other but they cannot see my communications and when I search for other rooms I get the message "Failed to fetch room list"

My old proxy configs looked like this before installing NPM:

For the matrix server-

    server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
    
        # For the federation port
        listen 8448 ssl http2 default_server;
        listen [::]:8448 ssl http2 default_server;
    
        server_name matrix.minnix.dev;
    
        location ~* ^(\/_matrix|\/_synapse\/client) {
            proxy_pass http://192.168.57.155:8008;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header Host $host;
    
            # Nginx by default only allows file uploads up to 1M in size
            # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
            client_max_body_size 50M;
        }
    
    }    

And for my parent domain-

    server {
    
            server_name minnix.dev;
    
         location /.well-known/matrix/server {
         return 200 '{"m.server": "matrix.minnix.dev:443"}';
         default_type application/json;
         add_header Access-Control-Allow-Origin *;
    
    }
    
         location /.well-known/matrix/client {
         return 200 '{"m.homeserver": {"base_url": "https://matrix.minnix.dev"}}';
         default_type application/json;
         add_header Access-Control-Allow-Origin *;
    
      }
    
    }

I have a feeling this can all be done with a single config as that's all that's listed within the official synapse documentation here

For the record I added these lines to the advanced tab to try and enable federation with no change:

listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;

I have transferred 12 other servers over to NPM without issue including Mastodon and Peertube which are federated, but matrix is not working for me.

Nginx Proxy Manager Version
v2.9.15

Expected behavior
Passing the federation test

Operating System
Armbian Focal Ubuntu server running on Rock64

@minnixtx minnixtx added the bug label Feb 26, 2022
@czadikem
Copy link

I just had this same issue. I ended up hosting the /.well-known/matrix/server file. Here is my example one https://gitlab.autiboystech.com/-/snippets/1 . Under nginx proxy I went to my domain name and did a custom location. I set the location to /.well-known/matrix/server and the scheme to http. The url I set to gitlab-ce/-/snippets/1/raw/main/matrix_server (my gitlab docker container). The port I set to 80 as that is the port gitlab runs on.

@minnixtx
Copy link
Author

Where should I put the /.well-known/matrix/server file since I am running matrix natively on its own machine and not through docker and I am not running nginx or NPM on the matrix server itself? I'm assuming my file should look like this:

{
    "m.server": "matrix.minnix.dev:443"
}

@czadikem
Copy link

You could use a github gist. At least thats what I would do and yes the above is what your file should look like.

@czadikem
Copy link

All you need is some type of url to a raw file.

@minnixtx
Copy link
Author

Ok I wasn't thinking straight. For some reason I thought it had to be on the matrix server itself. I'll host it on my blog and see what happens.

@czadikem
Copy link

When you get it to work be sure to close this and mark a solution.

@minnixtx
Copy link
Author

I tried it using a github gist and it doesn't work. Proxy host shows as offline whenever I hit save. I chose /.well-known/matrix/server as my location and for the second part scheme is https, forward hostname is https://gist.githubusercontent.com/minnixtx/18b65147c9293764add5350eb21e264a/raw/3c790731393885dd0667fd6ad4afd397f1cf75e4/matrix_server and port is 443.

@minnixtx
Copy link
Author

Ok here's what worked for me:

1.Create a proxy host for matrix.minnix.dev

Domain: matrix.minnix.dev
Scheme: http
Hostname: 192.168.57.155
Port: 8008

Under the advanced tab:

listen 8448 ssl http2 default_server;
listen [::]:8448 ssl http2 default_server;

Get SSL cert

  1. Create a proxy host for my parent domain minnix.dev

Domain: minnix.dev
Scheme: http
Hostname: 192.168.57.155
Port: 8008

Under the Advanced tab:

location /.well-known/matrix/server {
     return 200 '{"m.server": "matrix.minnix.dev:443"}';
     default_type application/json;
     add_header Access-Control-Allow-Origin *;

}

     location /.well-known/matrix/client {
     return 200 '{"m.homeserver": {"base_url": "https://matrix.minnix.dev"}}';
     default_type application/json;
     add_header Access-Control-Allow-Origin *;

  }

Get SSL cert

@czadikem
Copy link

The gist didn't work as your file was in the incorrect format

@AroPix
Copy link

AroPix commented Jul 23, 2022

thanks for this solution, but i dont seem to get it working that i can proxy host my matrix server on my matrix subdomain. how did you solve it with the custom paths? I just dont get it working.

@czadikem
Copy link

Are you using nginx?

@AroPix
Copy link

AroPix commented Jul 23, 2022

Are you using nginx?

I host the matrix on my home server, which is connected to my VPS via a VPN. I would like to use NPM without a extra Nginx server, but if that isnt possible it's going to make things harder for me.
Edit: It's just a plain matrix synapse docker without any additional components. (No external db, no webserver)

@czadikem
Copy link

Ok so I had all my stuff in docker. NPM comes with nginx by default so your good there. Do you have anything setup in NPM yet? Also what exactly isn't working and did you look at this https://github.com/spantaleev/matrix-docker-ansible-deploy ?/issues/1687

@AroPix
Copy link

AroPix commented Jul 23, 2022

The problem is that i don't know how to make the correct settings for it to work in NPM. Do you know how? Would be nice if you could contact me ^^ (discord: removed)

@czadikem
Copy link

I do now how to help you I just need to find my document I had.

@AroPix
Copy link

AroPix commented Jul 23, 2022

(he helped me and it wasnt a fault of npm, rather a misconfigured matrix server)

@RobertDWhite
Copy link

@czadikem @AroPix are you able to share the document and misconfigurations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants