nicknsy / jellyscrub

Smooth mouse-over video scrubbing previews for Jellyfin.
MIT License
670 stars 27 forks source link

Add instuction how to inject clientscript via nginx reverse proxy config #42

Open tam1m opened 2 years ago

tam1m commented 2 years ago

An alternative solution to inject the clientscript into the webclient.

This is using the Nginx ngx_http_sub_module module, works when using Nginx as reverse proxy in front of Jellyfin (regardless of install method) and does not require any file/owner/permissions changes as Nginx simply injects the code dynamically on request

bin101 commented 1 year ago

@tam1m I also had to disable caching in nginx for the /web/ location:

    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;
# disable caching
        add_header Last-Modified $date_gmt;
        add_header Cache-Control 'private no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
            if_modified_since off;
            expires off;
            etag off;
# inject Jellyscrub script into the webclient
        proxy_set_header Accept-Encoding "";
        sub_filter
            '</body>'
            '<script plugin="Jellyscrub" version="1.0.0.0" src="/Trickplay/ClientScript"></script>
            </body>';
        sub_filter_once on;
    }

Otherwise the inject sometimes didn't happen. Did you also faced this issue? Or maybe have a better solution?