全网最全的 qBittorrent 报错 Unauthorized 的解决办法。(方便搜索:如何为 qBittorrent 设置 Nginx 反向代理、qBittorrent 打不开、qBittorrent 网页版报错)

确保启动参数无误,尤其是配置文件的目录,必须是 qbittorrent 的父级目录,不可以到 qbittorrent 这一层。

如果你是在外网通过 IP 访问内网服务器,则需查看 qbittorrent.conf 中,是否设置了 WebUI\HostHeaderValidation=true 参数,如有,请改为 false。

如果你是在外网通过域名访问内网服务器,则第二条同样适用;但安全起见,建议改为 true 并把值设置为你的域名。

如果你并未配置 HTTPS 证书,或未安装相关组件,则需查看 qbittorrent.conf 中,是否设置了 WebUI\HTTPS\Enabled=ture 参数,如有,请改为 false。

若以上参数在配置文件里都没有,可自行添加,并设置为 false;若仍未解决,可在 webui 中尝试关闭跨站请求伪造(CSRF)保护。

如果你设置了 Nginx 反向代理,则需要根据官方 Wiki 设置以下参数(请删除其他所有参数):

proxy_pass http://127.0.0.1:30000/; # 根据你的 IP 地址和端口号修改

proxy_http_version 1.1;

proxy_set_header Host 127.0.0.1:30000; # 根据你的 IP 地址和端口号修改

proxy_set_header X-Forwarded-Host $http_host;

proxy_set_header X-Forwarded-For $remote_addr;

# 以下参数不适用于 qBittorrent!请务必移除(若有)

#proxy_set_header X-Forwarded-Proto $scheme;

#proxy_set_header X-Real-IP $remote_addr;

# 可选,设置后可一次性添加 100M 的种子

#client_max_body_size 100M;

# 从 4.2.2 版本起,若你在 qBittorrent 内部设置了 HTTPS,则不需要设置以下参数。否则,必须设置以下参数用以保证 Cookie 的安全性

proxy_cookie_path / "/; Secure";

参考链接:

https://www.cnblogs.com/dabai0030/articles/15976106.html

https://www.drixn.com/2362.html

https://blog.csdn.net/weixin_45120915/article/details/114691473

https://github.com/qbittorrent/qBittorrent/wiki/NGINX-Reverse-Proxy-for-Web-UI