ronggang / transmission-web-control

一个 Transmission 浏览器管理界面。Transmission Web Control is a custom web UI.
MIT License
4.65k stars 779 forks source link

使用nginx反代到二级目录下自动跳转的问题 #547

Open ycj1379 opened 3 years ago

ycj1379 commented 3 years ago

Transmission 版本:2.92 (14714), RPC: 15, WEB Control: 1.6.1(20200913) 多个浏览器问题都可以复现

使用nginx反代到二级目录/file下,想实现访问abc.xxx.com/file即可进行管理的目的。如果使用ip:9091访问,会跳转到ip:9091/transmission/web/下,理论上我的会自动跳转到abc.xxx.com/file/transmission/web/,实际上访问abc.xxx.com/file/,登录后会跳转到abc.xxx.com/transmission/web/,然后显示出错。 手动修改为abc.xxx.com/file/transmission/web/之后可以正常访问。 请问这个问题需要怎么解决呢?

nginx设置文件如下


    server {
    listen 443 ssl http2;
    listen [::]:443 http2;
        ssl_certificate       /data/v2ray.crt;
        ssl_certificate_key   /data/v2ray.key;
        ssl_protocols         TLSv1.3;
        ssl_ciphers           TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
    server_name abc.xxx.com;
        index index.html index.htm;
        root  /home/wwwroot/3DCEList;
        error_page 400 = /400.html;

        # Config for 0-RTT in TLSv1.3
        ssl_early_data on;
        ssl_stapling on;
        ssl_stapling_verify on;
        add_header Strict-Transport-Security "max-age=31536000";

location /file/ {
    proxy_set_header    X-Forwarded-Host $host:$server_port;
    proxy_set_header    X-Forwarded-Server $host;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass              http://127.0.0.1:9091/;
    }

    location /f0/
        {
        proxy_redirect off;
        proxy_read_timeout 1200s;
    proxy_pass http://127.0.0.1:405;
        proxy_http_version 1.1;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;

        # Config for 0-RTT in TLSv1.3
        proxy_set_header Early-Data $ssl_early_data;
        }

}
    server {
        listen 80;
        listen [::]:80;
    server_name abc.xxx.com;
    return 301 https://abc.xxx.com$request_uri;
    }
shNanChen commented 3 years ago

proxy_pass http://127.0.0.1:9091/; 改成 proxy_pass http://127.0.0.1:9091/transmission/web/; 试试看

ycj1379 commented 3 years ago

@shNanChen 仍然是跳转到abc.xxx.com/transmission/web/,如果手动加上/file/,就会提示404,/usr/share/transmission/web/transmission/web/ (No such file or directory)

Orokapei commented 3 years ago
    location ^~ /transmission {
        proxy_pass http://downloads:9091/transmission;
    }

我是这样写的

Orokapei commented 3 years ago

貌似有固定路由transmission,要么二级目录保持transmission名称,要么另外把网站的transmission二级目录重定向到file,之前琢磨过没得出其他解决办法= =

ycj1379 commented 3 years ago

@Orokapei 是的,其实只需要我输入二级目录能跳转就好,但是cf不开cdn不可以重定向,不知道通过nginx能不能实现,不太懂,都是抄网上的

Orokapei commented 3 years ago

@Orokapei 是的,其实只需要我输入二级目录能跳转就好,但是cf不开cdn不可以重定向,不知道通过nginx能不能实现,不太懂,都是抄网上的

试试加一条这个,我也不太懂,之前琢磨另一个程序的时候用的

    location ~ ^/transmission {
        return 307 /file$request_uri;
    }
imebeh commented 3 years ago

url中的 transmission 那部分可以改 settings.json 中的 rpc-url

https://github.com/transmission/transmission/wiki/rpc

我没试过 测试可行