Jellyfin Forum
Jellyfin reverse proxy with NPM 502 Bad Gateway - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+---- Forum: Networking & Access (https://forum.jellyfin.org/f-networking-access)
+---- Thread: Jellyfin reverse proxy with NPM 502 Bad Gateway (/t-jellyfin-reverse-proxy-with-npm-502-bad-gateway)



Jellyfin reverse proxy with NPM 502 Bad Gateway - powergrim1234 - 2024-02-25

I am having a problem that I just cannot wrap my head around.

I used to have a set-up of a Jellyfin server with some companion apps bare-metal on a fairly heavyweight and power-hungry server. I have switched that over to a more energy-efficient solution.

The former solution was exposed to the internet via NGinx Proxy Manager(NPM). This was working just fine. No additional configuration was set via de advanced tab in NPM.

But now that I have switched over to my newer machine things start working worse. I expose it through the same configuration as my former jellyfin server and it works for about 30 seconds. After that I get 502 Bad Gateway errors for about 5 tot 10 minutes and after that the next attempt works fine for about 30 seconds.

What I have tried sofar:

- Run with advanced configuration, several even. One from the officials docs, one from Reddit. All in all, no change in behaviour.
- Spun up a container instead of bare-metal. The result is the same
- Tried different setups regaring websocket support, no change at all
- Compared absolutely everything with my old server. I can't see anything different, and yet that machine is working fine (still is, haven't wiped it as of yet)

I am really lost as to how to fix this, I have read up how to spin up Traefik. But honestly, it just doesn't fit my usecase and I like the ease of NPM.

Couple of facts:

- DNS externally is Cloudflare. It is a full DNS passthrough
- Firewall has not been touched, it points to the reverse proxy
- Internal and external DNS names are fully different. So no weird internal lookups.
- Allow remote connections is enabled
- The proxy is listed in the networking tab of Jellyfin. Allthough I don't know if it will work. I put my dockerhost IP in there, would that be the issue?
- NPM is fully IP-based, and HTTPS enabled and forced for external connections
- NPM listens on 443, and is configured to redirect to port 8096.

Does anyone have the slightest idea what logfile would help me out of where to look to resolve this?


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - TheDreadPirate - 2024-02-26

What are the specs of the new server? What OS?

Can you share your jellyfin logs with us and docker compose files for nginx proxy manager and jellyfin.

Post the above to sourcebin or pastebin and link back here.


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - powergrim1234 - 2024-02-26

The new server is a low-powered machine with an Intel I3 8130u, 16GB ram, internal SSD, External HDD. It runs Ubuntu 22.04.4 LTS (uname -a result is: #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri FebĀ  9 13:32:52 UTC 2 x86_64 x86_64 x86_64).

https://pastebin.com/DqpedRMQ Jellyfin Log
https://pastebin.com/mWjDFV6J NPM Log

https://pastebin.com/wQrPh62j NPM Docker Compose

This is the log and compose. I`ve reverted my install back tot bare-metal after container didn't work either. So no compose file for Jellyfin.

Something I didn't mention earlier. But if the 502's are generated, it's only there for the reverse proxy connection. The internal webserver of Jellyfin just keeps running fine. Internally I have no issue to run this whatsoever.


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - TheDreadPirate - 2024-02-26

I'm assuming Jellyfin is using host networking. You have two options, I think. Switch nginx to host networking (you'd have to remove the ports since they're no longer needed) or put Jellyfin on the same bridge.

Putting nginx on host networking is the easiest and what I did for my test setup.


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - powergrim1234 - 2024-02-26

I`ll spin up another Jellyfin container and see what happens. Just to note, the dockerhost of Jellyfin and NPM are different.


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - powergrim1234 - 2024-02-26

That seems to be the trick. I`ve changed the NPM netwerk_mode to host and everything seems to be working fine now. Even with a bare-metal install of Jellyfin.

Any reason why it has to be like this? Every other application proxied by NPM works fine, only Jellyfin had issues.


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - TheDreadPirate - 2024-02-26

Are your other apps also in docker with bridge networking?


RE: Jellyfin reverse proxy with NPM 502 Bad Gateway - powergrim1234 - 2024-02-27

Yea those apps are hosted on a non-default bridgenetwork. All put in the same network as nginx proxy manager was. Some apps are hosted outside of that network, and they were working fine as well.

Now my situation is as follows. Some apps hosted on dockerhost1 in their non-default but shared bridge-network. NPM hosted on dockerhost1 on a host-network. Jellyfin installed on a seperate machine as a bare-metal application. And dockerhost2 hosts some services that are exposed through NPM on dockerhost1.