bunkerity / bunkerweb

🛡️ Open-source and next-generation Web Application Firewall (WAF)
https://www.bunkerweb.io
GNU Affero General Public License v3.0
6.46k stars 363 forks source link

[BUG] Bunkerweb messes with Jellyfin-Kodi playback (File ended prematurely error) #398

Open LeVraiRoiDHyrule opened 1 year ago

LeVraiRoiDHyrule commented 1 year ago

Description Connecting from Jellyfin for Kodi addon to a Jellyfin server reverse proxied through Bunkerweb creates errors during playback. Randomly (generally after 2-3 minutes into the playback), the playback fails with the error File ended prematurely in Kodi logs. (Full Kodi logs: https://paste.hostux.net/?e233fd10ea6fc475#99LpcuAJn34f6j6GU9MGSJq2m9D54DXGNYSPpqatj7ZY)

When this happens, Bunkerweb logs don't show anything in particular (except the information that the playback stopped ["POST /Sessions/Playing/Stopped HTTP/1.1" 204 0 "-" "Jellyfin-Kodi/0.7.10+py3")

I am 90% sure this comes from Bunkerweb as this happens to all Kodi clients on various machines (Windows, Odroid N2, Raspberry...) and connecting the same directly to the Jellyfin ports (without the reverse proxy) works like a charm.

After discussions with Jellyfin for Kodi addon team, they also think it comes from the reverse proxy.

Logs https://paste.hostux.net/?9bfad4864f7ed5be#GBydLkq7isndkP5VxQxpUNLPEKtMLn7E6sdKXA4zjgLs (private info edited)

Config Here is my config for Jellyfin (using autoconf):

    labels:
      - "bunkerweb.SERVER_NAME=stream.mydomain.com"
      - "bunkerweb.ALLOWED_METHODS=GET|POST|HEAD|DELETE|PUT"
      - "bunkerweb.USE_REVERSE_PROXY=yes"
      - "bunkerweb.REVERSE_PROXY_WS=yes"
      - 'bunkerweb.REVERSE_PROXY_BUFFERING=no'
      - 'bunkerweb.USE_LIMIT_REQ=no'
      - 'bunkerweb.USE_BAD_BEHAVIOR=no'
      - 'bunkerweb.MAX_CLIENT_SIZE=20M'
      - 'bunkerweb.USE_MODSECURITY=no'
      - 'bunkerweb.USE_BLACKLIST=no'

      - |
        bunkerweb.CUSTOM_CONF_SERVER_HTTP_jellyconf1=
        location / {
        # Proxy main Jellyfin traffic
        proxy_pass http://jellyfin:8096;
        proxy_set_header Host $$host;
        proxy_set_header X-Real-IP $$remote_addr;
        proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $$scheme;
        proxy_set_header X-Forwarded-Protocol $$scheme;
        proxy_set_header X-Forwarded-Host $$http_host;

        # Disable buffering when the nginx proxy gets very resource heavy upon streaming
        proxy_buffering off;
        }

      - |
        bunkerweb.CUSTOM_CONF_SERVER_HTTP_jellyconf2=
        # location block for /web - This is purely for aesthetics so /web/#!/ works instead of having to go to /web/index.html/#!/
        location = /web/ {
        # Proxy main Jellyfin traffic
        proxy_pass http://jellyfin:8096/web/index.html;
        proxy_set_header Host $$host;
        proxy_set_header X-Real-IP $$remote_addr;
        proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $$scheme;
        proxy_set_header X-Forwarded-Protocol $$scheme;
        proxy_set_header X-Forwarded-Host $$http_host;
        }

      - |
        bunkerweb.CUSTOM_CONF_SERVER_HTTP_jellyconf3=
        location /socket {
        # Proxy Jellyfin Websockets traffic
        proxy_pass http://jellyfin:8096;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $$http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $$host;
        proxy_set_header X-Real-IP $$remote_addr;
        proxy_set_header X-Forwarded-For $$proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $$scheme;
        proxy_set_header X-Forwarded-Protocol $$scheme;
        proxy_set_header X-Forwarded-Host $$http_host;
        }

Thanks in advance for any help or answer, have a great day

TheophileDiot commented 1 year ago

Hi @LeVraiRoiDHyrule, any updates on this issue ?