jellyfin / jellyfin-android

Android Client for Jellyfin
https://jellyfin.org
GNU General Public License v2.0
1.54k stars 249 forks source link

Android App might be interpreting the redirect incorrectly #1293

Closed plknkl closed 9 months ago

plknkl commented 9 months ago

I'm running the jellyfin server under nginx reverse proxy, routing with a subdomain, as in the guide. I could connect with every client, but had issues connecting to the server via Android app.

My server is reachable via https://mydomain.com/jellyfin and when checking the nginx log I noticed this attempt by the Android app

209.198.137.149 - - [11/Feb/2024:05:34:27 +0000] "GET /jellyfin/ HTTP/2.0" 302 0 "-" "Mozilla/5.0 (Linux; Android 13; KB2003 Build/RKQ1.211119.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.144 Mobile Safari/537.36" "-"
2024/02/11 05:34:27 [error] 9#9: *801 open() "/var/www/static/mydomain/web/index.html" failed (2: No such file or directory), client: 209.198.137.149, server: mydomain.com, request: "GET /web/index.html HTTP/2.0", host: "mydomain.com"
209.198.137.149 - - [11/Feb/2024:05:34:27 +0000] "GET /web/index.html HTTP/2.0" 404 548 "-" "Mozilla/5.0 (Linux; Android 13; KB2003 Build/RKQ1.211119.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/121.0.6167.144 Mobile Safari/537.36" "-"

So from what I understand the app looses the jellyfin/ prefix after the redirect with nginx.

My hacky solution right now is to add to the nginx configuration

location /web/index.html {
     return 301 $scheme://$host/jellyfin/web/index.html;
}

and everything works fine, but I guess it's fixable on the android client side.

PS I'll add an excerpt on my nginx conf in case it could be useful

location / {
    autoindex on;
    root /var/www/static/mydomain;
    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;
}

# hack
location /web/index.html {
    return 301 $scheme://$host/jellyfin/web/index.html;
}

# Jellyfin
location /jellyfin {
    return 302 $scheme://$host/jellyfin/;
}

# The / at the end is significant.
# https://www.acunetix.com/blog/articles/a-fresh-look-on-reverse-proxy-related-attacks/
location /jellyfin/ {
    # Proxy main Jellyfin traffic

    proxy_pass http://jellyfin:8096/;

    proxy_pass_request_headers on;

    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-Host $http_host;

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_http_version 1.1;
    proxy_set_header Connection "upgrade";

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

Logs

No response

Application version

2.6.0

Where did you install the app from?

F-Droid

Device information

Oneplus 8T

Android version

13

Jellyfin server version

10.8.13

Which video player implementations does this bug apply to?

nielsvanvelzen commented 9 months ago

Using a base URL should work, our demo server at demo.jellyfin.org/stable uses it and that works fine. Did you configure the base URL in the Jellyfin dashboard?

plknkl commented 9 months ago

if i add jellyfin to the baseurl field in the networking configuration, every client stop being able to connect. When I revert back to blank, everything start working again for both desktop and android apps

nielsvanvelzen commented 9 months ago

If you leave the baseurl blank, the redirect in the server will go to /web/index.html instead of /jellyfin/web/index.html. So this is a configuration error on your side.

plknkl commented 9 months ago

With baseurl blank and with plain nginx configuration as for your guide, so without my additional redirect:

So it seems strange to me that with baseurl blank, on all other systems the connection works, on android is not working, and it's because of my config fault..

I will try a couple of things on nginx config side and get back to you

plknkl commented 9 months ago

No luck with other nginx configuration attempts. If you do not want to investigate further you can close the issue, I will stick with my hacky configuration that let the Android app work that way.

nielsvanvelzen commented 9 months ago

I'll close the issue as it doesn't appear to be an issue with the app itself. You can always try our regular troubleshooting channels (Matrix/Forum/Discord) as there are more people there that can help with these kinds of issues.

dezza commented 3 months ago

My iOS app works fine and understands redirect, but when I tried from a friends Android phone or Swiftfin on AppleTV remotely it neither would connect. My setup is rather simple as well:

  return 301 https://[addr]:[port]$request_uri;