我在HTPC上安装了Transmission作为BT下载工具,并安装了WebUI通过浏览器进行管理,由于家庭对外开放的端口都由一台Linux机器做的Nginx反向代理,所以涉及到了用Nginx反代Transsmission的问题。

首先尝试了一下常规的反向代理设置,无法工作,研究了之后发现网页登录Transmission后是有一个Session-Id的,需要在配置文件中添加一个header,于是合理利用了一下搜索引擎。

Github中找到了一段代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
upstream transmission {
server 127.0.0.1:9091; #Transmission
}

server {
listen 443 ssl http2;
server_name example.com;
auth_basic "Server Restricted";
auth_basic_user_file /var/www/myWebSite/web/.htpasswd;

# Path to the root of your installation
error_log /var/www/myWebSite/logs/error.log;
access_log /var/www/myWebSite/logs/access.log;

### SSL cert files ###
ssl_certificate /var/www/myWebSite/ssl/advert.crt;
ssl_certificate_key /var/www/myWebSite/ssl/advert.key;

### Add SSL specific settings here ###
ssl_session_timeout 10m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
ssl_prefer_server_ciphers on;

location / {
return 301 https://$server_name/transmission/;
}

location ^~ /transmission {
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;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass_header X-Transmission-Session-Id;
add_header Front-End-Https on;

location /transmission/rpc {
proxy_pass http://transmission;
}

location /transmission/web/ {
proxy_pass http://transmission;
}

location /transmission/upload {
proxy_pass http://transmission;
}

location /transmission/web/style/ {
alias /usr/share/transmission/web/style/;
}

location /transmission/web/javascript/ {
alias /usr/share/transmission/web/javascript/;
}

location /transmission/web/images/ {
alias /usr/share/transmission/web/images/;
}

location /transmission/ {
return 301 https://$server_name/transmission/web;
}
}
}

初步读了一遍,配置文件中的/style//javascript//images/这三个location块应该是适用于Nginx与Transmission安装在同一台主机时使用的,于是我把它注释掉。

重启Nginx后使用一切正常。

我在想,就算Nginx与Transmission安装在同一台主机,如果不注释掉那三个location块,会不会也用不了自己安装的WebUI。


本站由 澄哥 使用 Stellar 主题创建。


本页点击量本站点击量次。
您是本站的第个小伙伴
本站已稳定运行