Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Xarth-Mai opened this issue Nov 18, 2023 · 1 comment
Closed

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

Xarth-Mai opened this issue Nov 18, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@Xarth-Mai
Copy link

Xarth-Mai commented Nov 18, 2023

使用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版本不全相同,使用时请根据实际情况调整

@Xarth-Mai Xarth-Mai added the enhancement New feature or request label Nov 18, 2023
@Xarth-Mai Xarth-Mai changed the title 一种更新更优雅的服务端持久化侧载脚本方式 一种更新更优雅的服务端持久化侧载脚本实现 Nov 18, 2023
@Izumiko
Copy link
Owner

Izumiko commented Nov 19, 2023

感谢,我抽空更新一下readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants