matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
465 stars 150 forks source link

Provide example Nginx reverse-proxy config for new media-proxy? #1820

Open poVoq opened 3 weeks ago

poVoq commented 3 weeks ago

The media proxy seems to be working as expected, but I am still having some issue finding the right config for the reverse-proxy to serve the files on a sub-directory.

I can imagine that others will have the same issue, so it would be nice if there was a sample config for Nginx provided in this repo.

Thanks!

Edit: hmm, no can't get it to work. Always a 502 gateway error. Any tips appreciated.

poVoq commented 3 weeks ago

So I was told that this should work with Nginx:

    location /media/ {
        proxy_pass http://127.0.0.1:11111/;

        proxy_set_header X-Forwarded-For $remote_addr;
    }

But I still get a 502 error when I try that with my setup proxying to the address of the container instead.

Is it possible that appservice-irc only listens on localhost? That obviously can't work in Docker containers or when the reverse-proxy isn't on the same machine.

voice06 commented 3 weeks ago

Thats from my setup, I did take a quick look at the code for media-proxy and it looks like it will always start the service on 0.0.0.0.

The question becomes what is your publicUrl set to? For that nginx location example and my server I have it set to: publicUrl: "https://matrix.randomsonicnet.org/media"

You'll probably need to tinker around with the media-proxy and nginx config till it just works since thats basically what I ended up doing.

Also before I forget, currently homeserver.url has to be http, https is currently not supported from the errors I got.

poVoq commented 3 weeks ago

Ok that is good to know that it listens on 0.0.0.0. so running it in a container should be fine then.

I guess I need to get back to trail and error with my Nginx then.

poVoq commented 1 week ago

Ok, I figured out what the issue was (the pod didn't allow access to port 11111, stupid me), but now I always get a "cannot GET /media/v1/...." error.

The Url displayed in the error seems to be correct, so I wonder what the issue might be now.