Comments (6)
Hi, the best way to get this addressed would be to edit the file and submit a PR.
The file for nginx is this one: https://github.com/jellyfin/jellyfin.org/blob/master/docs/general/networking/nginx.md
from jellyfin.org.
@felix920506 I've neither created a pull request before nor do I know how to do it. Can you edit the file and submit the PR?
The changes are indicated by the diff below:
--- original/nginx.md 2024-01-17 20:53:49.732564945 +0300
+++ modified/nginx.md 2024-01-17 21:28:23.542564154 +0300
@@ -158,12 +158,6 @@
# You can specify multiple domain names if you want
#server_name jellyfin.local;
- # use a variable to store the upstream proxy
- # in this example we are using a hostname which is resolved via DNS
- # (if you aren't using DNS remove the resolver line and change the variable to point to an IP address e.g `set $jellyfin 127.0.0.1`)
- set $jellyfin jellyfin;
- resolver 127.0.0.1 valid=30;
-
# Uncomment and create directory to also host static content
#root /srv/http/media;
index index.html;
@@ -182,8 +176,10 @@
# The / at the end is significant.
# https://www.acunetix.com/blog/articles/a-fresh-look-on-reverse-proxy-related-attacks/
+ # Using a variable to store the upstream server address results in endless redirection loop (chromium: "ERR_TOO_MANY_REDIRECTS", Firefox: "The page isn’t redirecting properly"). So don't use a variable.
+ # JELLYFIN_HOST = IP address or hostname of machine running jellyfin server e.g localhost, 127.0.0.1, 192.168.1.2, etc.
- proxy_pass http://$jellyfin:8096/jellyfin/;
+ proxy_pass http://JELLYFIN_HOST:8096/jellyfin/;
proxy_pass_request_headers on;
@@ -234,11 +230,6 @@
ssl_trusted_certificate /etc/letsencrypt/live/DOMAIN_NAME/chain.pem;
ssl_stapling on;
ssl_stapling_verify on;
- # use a variable to store the upstream proxy
- # in this example we are using a hostname which is resolved via DNS
- # (if you aren't using DNS remove the resolver line and change the variable to point to an IP address e.g `set $jellyfin 127.0.0.1`)
- set $jellyfin jellyfin;
- resolver 127.0.0.1 valid=30;
# Jellyfin
location /jellyfin {
@@ -250,8 +241,10 @@
# The / at the end is significant.
# https://www.acunetix.com/blog/articles/a-fresh-look-on-reverse-proxy-related-attacks/
+ # Using a variable to store the upstream server address results in endless redirection loop (chromium: "ERR_TOO_MANY_REDIRECTS", Firefox: "The page isn’t redirecting properly"). So don't use a variable.
+ # JELLYFIN_HOST = IP address or hostname of machine running jellyfin server e.g localhost, 127.0.0.1, 192.168.1.2, etc.
- proxy_pass http://$jellyfin:8096;
+ proxy_pass http://JELLYFIN_HOST:8096/jellyfin/;
proxy_pass_request_headers on;
@@ -328,7 +321,7 @@
proxy_cache_lock on;
proxy_cache_lock_age 60s;
- proxy_pass http://$jellyfin:8096;
+ proxy_pass http://127.0.0.1:8096;
proxy_cache_key "jellyvideo$uri?MediaSourceId=$arg_MediaSourceId&VideoCodec=$arg_VideoCodec&AudioCodec=$arg_AudioCodec&AudioStreamIndex=$arg_AudioStreamIndex&VideoBitrate=$arg_VideoBitrate&AudioBitrate=$arg_AudioBitrate&SubtitleMethod=$arg_SubtitleMethod&TranscodingMaxAudioChannels=$arg_TranscodingMaxAudioChannels&RequireAvc=$arg_RequireAvc&SegmentContainer=$arg_SegmentContainer&MinSegments=$arg_MinSegments&BreakOnNonKeyFrames=$arg_BreakOnNonKeyFrames&h264-profile=$h264Profile&h264-level=$h264Level&slicerange=$slice_range";
# add_header X-Cache-Status $upstream_cache_status; # This is only for debugging cache
git commit description: Don't use a variable to store the jellyfin upstream server address for nginx with subpath
Apply the patch with $ patch -u -i endless_redirect.patch docs/general/networking/nginx.md
Extended description: Using a variable to store the upstream server address results in endless redirection loop. On chromium-based browsers, the error is: "This page isn't working. <domain_name> redirected you too many times. ERR_TOO_MANY_REDIRECTS". On firefox-based browsers, the error is :"The page isn’t redirecting properly. The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete"
Interestingly, using a variable for jellyfin from a subdomain on nginx works just fine with no such errors.
from jellyfin.org.
from jellyfin.org.
After much testing I've come to realize that the endless redirect loop issue for Nginx with subpath was rather simple to fix. It was caused by the trailing /jellyfin/
in the proxy_pass directive. I've filed PR #830 that fixes it.
Why does this happen? Normally in Nginx if we put trailing slash /
at the end of the proxy_pass
directive with a variable, it will ONLY proxy /
to jellyfin server without the entire URI. Jellyfin then redirects to /jellyfin
and nginx redirects /jellyfin
to /jellyfin/
location block which contains the which contains the problematic trailing slash in the proxy_pass
directive causing the redirection cycle to begin again, endlessly. (source: https://distinctplace.com/2017/04/19/nginx-resolver-explained/)
The potential problem with the solution proposed in this comment is explained in https://distinctplace.com/2017/04/19/nginx-resolver-explained/ which basically says that when you specify hostname for proxy_pass
rather than a static IP address, Nginx will resolve it only once on startup or reload and then cache resulting IP address indefinitely until it's restarted or reloaded. This becomes problematic if the IP address of the jellyfin hostname changes frequently, because then the Nginx-cached IP address would be invalid and may end up proxying some other site or replying 502 bad gateway. If using a static IP address, or a hostname with a static IP address, then the solution would work.
from jellyfin.org.
Now that #830 is merged, can this be closed?
from jellyfin.org.
Yeah, the issue is fixed.
from jellyfin.org.
Related Issues (20)
- Enable the possibility of select light mode
- Provide working download links for Widnows portable archives on the website
- 10.9.3 still get 404 on webUI even update the nginx settings HOT 1
- Route metadata downloads through proxy HOT 1
- [Feature request]Sort recommended/all clients by date-added in the .org/downloads page
- request: document unix socket binding HOT 4
- Improve installation instructions for rootless podman containers
- Demo site is not clear with log-in credentials. HOT 2
- Update Live-TV documentation and setup guide (There was an error saving the TV provider)
- Possibly incorrect nginx configuration in docs when using jellyfin in a docker container
- [Todo]: Testing Documentation HOT 1
- Admonition Guidelines
- Add Delfin to Client list HOT 2
- Movies folder structure needs clarification in the docs
- Refactor Contacts page
- Cleanup 10.8 things
- Improve documentation for discovery ports HOT 1
- Adding instructions for device passthrough with LXC containers (unprivileged also)
- Switch Networking Traefik docs for `network_mode: "host"` to match Traefik's docs using `extra_hosts:` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jellyfin.org.