Getting 502 errors when reverse proxying

1. The problem I’m having:

I am unable to reverse proxy my Jellyfin instance as I get a 502 bad gateway error

2. Error messages and/or full log output:

2024/05/09 08:48:42.779	INFO	using adjacent Caddyfile
2024/05/09 08:48:42.781	WARN	Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies	{"adapter": "caddyfile", "file": "Caddyfile", "line": 2}
2024/05/09 08:48:42.783	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2024/05/09 08:48:42.783	INFO	http.auto_https	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "srv0", "https_port": 443}
2024/05/09 08:48:42.783	INFO	http.auto_https	enabling automatic HTTP->HTTPS redirects	{"server_name": "srv0"}
2024/05/09 08:48:42.783	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0xc0004a1100"}
2024/05/09 08:48:42.784	INFO	http	enabling HTTP/3 listener	{"addr": ":443"}
2024/05/09 08:48:42.784	INFO	http.log	server running	{"name": "srv0", "protocols": ["h1", "h2", "h3"]}
2024/05/09 08:48:42.784	INFO	http.log	server running	{"name": "remaining_auto_https_redirects", "protocols": ["h1", "h2", "h3"]}
2024/05/09 08:48:42.785	INFO	http	enabling automatic TLS certificate management	{"domains": ["jellyfin.aaronrodrigues.com"]}
2024/05/09 08:48:42.786	INFO	autosaved config (load with --resume flag)	{"file": "/root/.config/caddy/autosave.json"}
2024/05/09 08:48:42.786	INFO	serving initial configuration
2024/05/09 08:48:42.833	WARN	tls	storage cleaning happened too recently; skipping for now	{"storage": "FileStorage:/root/.local/share/caddy", "instance": "efcbbcd2-a93a-4799-850b-038970d25ca2", "try_again": "2024/05/10 08:48:42.833", "try_again_in": 86399.999998981}
2024/05/09 08:48:42.833	INFO	tls	finished cleaning storage units
2024/05/09 08:54:35.169	ERROR	http.log.error	dial tcp 192.168.1.113:8096: connect: connection refused	{"request": {"remote_ip": "192.168.1.99", "remote_port": "54620", "client_ip": "192.168.1.99", "proto": "HTTP/2.0", "method": "GET", "host": "jellyfin.aaronrodrigues.com", "uri": "/", "headers": {"Sec-Fetch-Mode": ["navigate"], "User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Safari/605.1.15"], "Accept-Language": ["en-GB,en;q=0.9"], "Sec-Fetch-Dest": ["document"], "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"], "Sec-Fetch-Site": ["none"], "Cookie": [], "Accept-Encoding": ["gzip, deflate, br"]}, "tls": {"resumed": false, "version": 772, "cipher_suite": 4867, "proto": "h2", "server_name": "jellyfin.aaronrodrigues.com"}}, "duration": 0.00068901, "status": 502, "err_id": "6i6tbkgm2", "err_trace": "reverseproxy.statusError (reverseproxy.go:1267)"}

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

a. System environment:

Debian 6.1.90-1 x64
Has docker containers running (pi-hole, Jellyfin, librenms)

b. Command:

sudo caddy run

d. My complete Caddy config:

jellyfin.aaronrodrigues.com {
        handle {
                reverse_proxy 192.168.1.113:8096 {
                }
        }
}

5. Links to relevant resources:

Are you sure this is the right IP address? How are you running Jellyfin?

This is a networking problem between Caddy and your upstream app, not a problem with Caddy itself.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.