Caddy with Jellyfin creates an error when i try to watch a movie

1. The problem I’m having:

Hi !
First, i would like to point out that I am a beginner in these type of things.

I am trying to set a proxy for my media server (jellyfin). My current server has a domain name with no Ip. I managed to create the proxy and access jellyfin on my server with HTTPS but when i try to listen to a media, it keeps loading and i receive non-stop errors on my server.

2. Error messages and/or full log output:

2023/03/25 04:20:24.897 ERROR   http.handlers.reverse_proxy     aborting with incomplete response       {"error": "context canceled"}
2023/03/25 04:20:24.972 ERROR   http.handlers.reverse_proxy     aborting with incomplete response       {"error": "http2: stream closed"}

3. Caddy version:

v2.6.4

4. How I installed and ran Caddy:

I installed Caddy with the official installation methods.

a. System environment:

UbuntuServer 22.04 (not in a docker)

b. Command:

cd /var/lib
caddy start

c. Service/unit/compose file:


d. My complete Caddy config:

gonpass.ddns.net {
        reverse_proxy 127.0.0.1:8096
}

5. Links to relevant resources:

I strongly recommend running Caddy as a systemd service. If you installed Caddy using our apt repo, that should be set up for you already.

Using caddy start should only be used for quick-and-dirty development tasks, not for a long-running Caddy instance.

Can you check Jellyfin’s logs? It might reveal the problem.

I run Jellyfin and I don’t have that problem myself.

I tried starting caddy with systemctl but here’s the logs. I’m not quite sure what i should put in the config file and how to use the Caddyfile i used.

Your Caddyfile syntax is invalid. You have a colon where there shouldn’t be one.

First I’d like to thank you for your help !

I fixed the config file and started the service, but just like last time. I can access the website on https but when i try to watch a movie i keep getting the same error. I’ll put bellow my config file, the status of the service and the error I’m getting.

gonpass.ddns.net {
        # Set this path to your site's directory.
        root * /usr/share/caddy

        # Enable the static file server.
        file_server

        # Another common task is to set up a reverse proxy:
        reverse_proxy localhost:8096

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

 caddy.service - Caddy
     Loaded: loaded (/lib/systemd/system/caddy.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-03-26 02:52:27 UTC; 11min ago
       Docs: https://caddyserver.com/docs/
    Process: 7184 ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force (code=exited, status=0/SUCCESS)
   Main PID: 7152 (caddy)
      Tasks: 10 (limit: 9257)
     Memory: 13.9M
        CPU: 8.874s
     CGroup: /system.slice/caddy.service
             └─7152 /usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
Mar 26 02:57:06 benserver caddy[7152]: {"level":"error","ts":1679799426.7718875,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"http2: stream closed"}
Mar 26 02:57:06 benserver caddy[7152]: {"level":"error","ts":1679799426.9986258,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"http2: stream closed"}

Remove this stuff from your config, it’s not useful. That’s just meant to act as a basic example of what you can do with the Caddyfile, you shouldn’t leave it in when you write your own config.

:point_up: did you look at your Jellyfin logs?

I’ll put bellow the logs created when i start the service and the first log that comes out when i access the proxy to listen to a movie

Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0479639,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"warn","ts":1679804819.0488148,"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":13}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.049778,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0507143,"logger":"http","msg":"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}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0507426,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0507634,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00036c070"}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0509803,"logger":"http","msg":"enabling HTTP/3 listener","addr":":443"}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0509837,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0510519,"msg":"failed to sufficiently increase receive buffer size (was: 208 kiB, wanted: 2048 kiB, got: 416 kiB). See https://github.com/quic-go/quic-go/wiki/UDP-Receive-Buffer-Size for details."}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0511026,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0511322,"logger":"http.log","msg":"server running","name":"remaining_auto_https_redirects","protocols":["h1","h2","h3"]}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0511386,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["gonpass.ddns.net"]}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0514271,"logger":"tls","msg":"finished cleaning storage units"}
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0518007,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Mar 26 04:26:59 benserver systemd[1]: Started Caddy.
Mar 26 04:26:59 benserver caddy[7989]: {"level":"info","ts":1679804819.0532236,"msg":"serving initial configuration"}
Mar 26 04:30:43 benserver caddy[7989]: {"level":"error","ts":1679805043.0096772,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"http2: stream closed"}

Those are your Caddy logs. I mean your logs from Jellyfin itself.

Oh my bad, here are the logs when i connect to jellyfin and try to open a movie

Mar 26 04:45:26 benserver jellyfin[865]: [04:45:26] [INF] WS <PublicIP> request
Mar 26 04:45:40 benserver jellyfin[865]: [04:45:40] [INF] User policy for ben. EnablePlaybackRemuxing: True EnableVideoPlaybackTranscoding: True EnableAudioPlaybackTranscoding: True
Mar 26 04:45:40 benserver jellyfin[865]: [04:45:40] [INF] StreamBuilder.BuildVideoItem( Profile=Anonymous Profile, Path=/hdd/movies/Rain Man 1988 Full movie online MyFlixer.mp4, AudioStreamIndex=null, SubtitleStreamIndex=null ) => ( PlayMethod=DirectPlay, TranscodeReason=0 ) media:/videos/7be9ce2a-0474-2b03-1b7f-a7d991de2589/stream.mp4?MediaSourceId=7be9ce2a04742b031b7fa7d991de2589&Static=true&VideoCodec=h264&AudioCodec=aac&AudioStreamIndex=1&api_key=<token>&SubtitleMethod=Encode&Tag=5c364bffc72e6bf3573683c1c62aec91

Do you believe the cause of my issue could be in my jellyfin config because i have not seen a similar issue with jellyin and caddy online.

I guess a couple things you could try is these two options for reverse_proxy – try them separately and see if either of them changes the behaviour:

flush_interval -1

OR

transport http {
	versions 1.1
}

I tried both and here are the results

Transport :

 Error: adapting config using caddyfile: /etc/caddy/Caddyfile:23: unrecognized directive: versions
gonpass.ddns.net {
        # Set this path to your site's directory.


        # Enable the static file server.
        # Another common task is to set up a reverse proxy:
        reverse_proxy localhost:8096

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}
transport http {
        versions 1.1
}

Flush_interval ( The service started but got the same result as before )

: {"level":"error","ts":1680296262.3345351,"logger":"tls.obtain","msg":"will retry","error":"[-1] Obtain: [-1] creating new order: attempt 1: https://acme.zerossl.com/v2/DV9>
Mar 31 20:57:42 benserver caddy[9879]: {"level":"error","ts":1680296262.8678691,"logger":"tls.obtain","msg":"could not get certificate from issuer","identifier":"flush_interval","issuer":"acme.zerossl.com-v2-DV>
Mar 31 20:57:42 benserver caddy[9879]: {"level":"error","ts":1680296262.8679168,"logger":"tls.obtain","msg":"will retry","error":"[flush_interval] Obtain: [flush_interval] creating new order: attempt 1: https:/>
lines 952-1000/1000 (END)
gonpass.ddns.net {
        # Set this path to your site's directory.


        # Enable the static file server.
        # Another common task is to set up a reverse proxy:
        reverse_proxy localhost:8096

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}
flush_interval -1

Those are subdirectives of reverse_proxy. See how the Caddyfile is structured: Caddyfile Concepts — Caddy Documentation

Try this:

gonpass.ddns.net {
	reverse_proxy localhost:8096 {
		flush_interval -1
	}
}
gonpass.ddns.net {
	reverse_proxy localhost:8096 {
		transport http {
			versions 1.1
		}
	}
}

Make sense, sorry about that. Unfortunately I got the same error as before for both

 {"level":"error","ts":1680297803.0358062,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"http2: stream closed"}

@gonpass I also proxy Jellyfin but with no problems. What client/browser are you using that is resulting in this error?

I’ve tried edge and google chrome and both resulted in the same error unfortnuately.

Huh. I usually use Firefox so I just tried it with Chrome including from a different machine (so it goes over a network) and it worked fine for me. :man_shrugging: My config is identical to yours in the first post in this topic.

What’s your network topology like?

PS. Is this for videos or just audio? I tried video. The title says “watch a movie” but the post says “listen” so I want to be sure.

yeah sorry about the confusion, i mean watching a movie.

I’m not quite sure what my topology is but from what i read online i believe I have a regular star stopology. My server is connected to a router where i do a port forwarding in order to access my server from outside the LAN.

1 Like

Ok, good to know. Does the error happen when you’re inside your network? Outside the network? What about from the mobile app? (Try toggling your phone’s wifi for a quick switch between internal and external access.)

I suspect something in the middle is disrupting the connection.

So i tried on my phone with the application and it strangely worked when i was connected to the wifi and when i wasn’t. But I did get an error

Apr 02 21:18:55 benserver caddy[20629]: {"level":"error","ts":1680470335.6094565,"logger":"http.handlers.reverse_proxy","msg":"aborting with incomplete response","error":"write tcp 10.0.0.35:443->204.48.93.50>

What i found out is that my app that controls the port forwarding believes that my server has the ip 10.0.0.35 but that’s not the actual ip address. When i went into my router’s settings i could see there my actual ip address connected to the server. I don’t know if it changes anything but i wanted to point it out just in case.

ps: Even tough the app believes the ip address is 10.0.0.35 the request does get redirected to the server