我安装了 qBittorrent docker。我在我的路由器上进行了转发;然后是使用 nginx 的反向代理;最后,docker 端口映射。
链条是:
[Port forwarding on Router]:
<WAN's IP>:44383 --> 192.168.10.254:44383
[Nginx]:
44383 --> 44373
[qBittorrent Docker]:
44373 --> 8083
Nextcloud docker 以同样的方式完成,它对我有用。但它对 qBittorrent 失败了。
这是 docker-compose.yml:
admin@pve:~/docker-qbittorrent$ cat docker-compose.yml
version: "2"
services:
qbittorrent:
image: linuxserver/qbittorrent
container_name: qbittorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
- UMASK_SET=022
- WEBUI_PORT=8073
#- WEBUI_PORT=8080
#- DOMAIN=https://example.com
volumes:
- ./config:/config
- ./downloads:/downloads
ports:
- "6881:6881/tcp"
- "6881:6881/udp"
- "44373:8073"
#- "44373:8080"
restart: unless-stopped
和 qbittorrent.conf:
admin@pve:~/docker-qbittorrent$ cat config/qBittorrent/qBittorrent.conf
[AutoRun]
enabled=false
program=
[LegalNotice]
Accepted=true
[Network]
Cookies=@Invalid()
[Preferences]
Connection\PortRangeMin=6881
Connection\UPnP=false
Downloads\SavePath=/downloads/
Downloads\ScanDirsV2=@Variant(\0\0\0\x1c\0\0\0\0)
Downloads\TempPath=/downloads/incomplete/
WebUI\Address=*
WebUI\Port=8073
WebUI\ServerDomains=*
这是 nginx 配置文件:
admin@pve:/etc/nginx/sites-available$ cat ../sites-enabled/docker-qbittorrent
server {
listen 8083;
server_name example.com;
# return 301 https://$host$request_uri;
}
server {
# listen 44383 ssl http2;
listen 44383;
server_name example.com;
ssl on;
ssl_certificate /etc/ssl/certs/example.com.pem;
ssl_certificate_key /etc/ssl/certs/example.com.key;
location / {
proxy_redirect off;
proxy_pass http://127.0.0.1:44373;
proxy_set_header Host $http_host;
}
}
docker 似乎工作正常:
admin@pve:~/docker-qbittorrent$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8e7b4c80c1ea linuxserver/qbittorrent "/init" 3 hours ago Up 3 hours 0.0.0.0:6881->6881/tcp, 0.0.0.0:6881->6881/udp, 8080/tcp, 0.0.0.0:44373->8073/tcp qbittorrent
但是我无法访问 webUI:
admin@pve:~/docker-qbittorrent$ curl localhost:6881
curl: (52) Empty reply from server
admin@pve:~/docker-qbittorrent$ curl localhost:44373
<No output here>
admin@pve:~/docker-qbittorrent$ curl https://example.com:44383
<No output here>
我使用 chrome 浏览器得到一个空白网页。
但在 docker 中,webUI 似乎没问题:
admin@pve:~/docker-qbittorrent$ docker exec -ti qbittorrent bash
root@8e7b4c80c1ea:/# curl localhost:8073
<!DOCTYPE html>
...
</html>
有人能帮忙吗?谢谢!
我遇到了类似的问题,因为传入的 HTTP header 的来源被过滤掉了。出于某种原因,WebUI\ServerDomains=*
配置无法正常工作。我也有 WebUI\HostHeaderValidation=false
,但也没有用。
将 network_mode: "host"
添加到配置并删除端口映射解决了问题。
我是一名优秀的程序员,十分优秀!