gpt4 book ai didi

nginx - 在 nginx 上重写 plex 媒体服务器 url?

转载 作者:行者123 更新时间:2023-12-02 01:50:13 24 4
gpt4 key购买 nike

我对在 nginx 中重写 url 的知识非常有限。我有一个 plex 媒体服务器在 nginx 上运行,我可以使用 http://domain.com/web/index.html 访问仪表板使用我在 github 上找到的这些配置:

upstream plex-upstream {
server plex-server.example.com:32400;
}

server {
listen 80;
server_name domain.com

location / {
if ($http_x_plex_device_name = '') {
rewrite ^/$ http://$http_host/web/index.html;
}

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;

proxy_set_header Host $http_host;
proxy_pass http://plex-upstream;
}
}

我想要的是删除/web/index.html 所以当我去 http://domain.com 时,PMS 仪表板将加载。我已经尝试了一些线性重写规则,但都失败了。谢谢。

最佳答案

我不是 nginx 专家,但我遇到了类似的问题。
不同之处在于我没有尝试将 domain.name/别名为 domain.name/web/,
我的目标是将 domain.name/plex/别名为 domain.name/web/。
我正在使用我能找到的所有解决方案重定向到 web/index.html Configure Plex Media Server Reverse Proxy nginx Linux .

这个唯一的一个问题是,如果你上网/你会留在那里。

所以这是我令人毛骨悚然但有效的解决方案:

upstream plex {
server localhost:32400;
}

server {
listen 80;
server_name domain.name;
server_name_in_redirect off;

location / {
proxy_pass http://localhost:8888;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;

# Enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}

location /web/index.html {
if ($http_x_should_not_redirect = ""){
return 301 https://domain.name/plex/index.html;
}

proxy_pass https://plex;
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_should_not_redirect $host;
}

location /web {
proxy_pass https://plex;
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_should_not_redirect $host;
}

location /plex {
proxy_pass https://127.0.0.1/web;
proxy_set_header X-should-not-redirect $host;
}



location /transmission/rpc {
proxy_pass http://localhost:9091;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;

# Enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}


location /transmission/web {
proxy_pass http://localhost:9091;

proxy_pass_header X-Transmission-Session-Id;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# Enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dovgastreetnas.viewdns.net/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dovgastreetnas.viewdns.net/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}

希望这会帮助某人。

关于nginx - 在 nginx 上重写 plex 媒体服务器 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23244301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com