Izumiko / jellyfin-danmaku

Jellyfin danmaku extension
MIT License
130 stars 12 forks source link

一种更新更优雅的服务端持久化侧载脚本实现 #8

Closed Xarth-Mai closed 9 months ago

Xarth-Mai commented 9 months ago

使用Nginx反向代理Jellyfin并在location块中插入:

#禁用与后端压缩并侧载脚本
proxy_set_header Accept-Encoding "";
sub_filter '</body>' '<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>';
sub_filter_once on;

即可由Nginx完成插入:

image

更完整的Nginx配置实例:

    location / {
        proxy_pass http://127.0.0.1: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_buffering off;
    }

    location = /web/index.html {
        return 301 /web/;
    }

    location = /web/ {
        proxy_pass http://127.0.0.1:8096/web/;
        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 Accept-Encoding "";
        sub_filter '</body>' '<script src="https://jellyfin-danmaku.pages.dev/ede.user.js" defer></script></body>';
        sub_filter_once on;
    }

        location /socket {
        proxy_pass http://127.0.0.1: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;
    }

不同Jellyfin版本不全相同,使用时请根据实际情况调整

Izumiko commented 9 months ago

感谢,我抽空更新一下readme