Jellyfin Forum
NGINX Reverse Proxy Redirect Looping - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: NGINX Reverse Proxy Redirect Looping (/t-nginx-reverse-proxy-redirect-looping)



NGINX Reverse Proxy Redirect Looping - william- - 2024-03-13

Hey all! I've got jellyfin and nginx both running in separate containers on the same machine and I'm having a hard time getting nginx to pass requests back to jellyfin properly. I want to be able to access this at apps.home/jellyfin. The initial visit seems to work correctly, but then the redirect to /web/index just keeps redirecting over and over again forever. I have set the base url setting in jellyfin to be "/jellyfin".

I've tried removing the trailing / on proxy_pass http://apps.home:8096;, but then I just get 404 from nginx.

Any thoughts?


server {
    listen 80;
    server_name apps.home;

    location /jellyfin/ {
    proxy_pass http://apps.home: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_buffering off;
    }
}



docker run -d \
  --name jellyfin \
  --user $(id -u):$(id -g) \
  -v /mnt/nfs/media/movies:/media/movies \
  -v /mnt/nfs/media/shows:/media/shows \
  -v /mnt/nfs/media/shorts:/media/shorts \
  -v /srv/jellyfin/config:/config \
  -v /srv/jellyfin/cache:/cache \
  -p 8096:8096 \
  jellyfin/jellyfin



docker run -d --name apps-nginx --restart=always -p 80:80 -p 443:443 apps-nginx



FROM nginx:latest

COPY sites-available/ /etc/nginx/sites-available/
COPY nginx.conf /etc/nginx/nginx.conf

EXPOSE 80 443

RUN mkdir -p /etc/nginx/sites-enabled
RUN ln -s /etc/nginx/sites-available/jellyfin.conf /etc/nginx/sites-enabled/

CMD ["nginx", "-g", "daemon off;"]



user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include      /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                '$status $body_bytes_sent "$http_referer" '
                '"$http_user_agent" "$http_x_forwarded_for" '
                '-> $upstream_addr';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush    on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-available/*.conf;
}



RE: NGINX Reverse Proxy Redirect Looping - TheDreadPirate - 2024-03-14

You can't use the apps.home as both the server_name and the proxy pass address. For the proxy pass you need to provide an IP or, if you're using a host name, you need to provide a resolver.


RE: NGINX Reverse Proxy Redirect Looping - william- - 2024-03-17

I forgot to mention that I have a local dns record setup for apps.home.

Turns out that my configuration above did work, I just needed to restart the jellyfin container for the base url to work correctly.