nginx - Kubernetes qBitTorrentWebUI 仅在路径“/”上显示
问题描述
我正在尝试使用 Kubernetes 托管 qBitTorrent 服务器。我为https://hub.docker.com/r/linuxserver/qbittorrent
docker 容器编写了一个 YAML。
问题是它只能从路径 / 访问。一旦我将它移动到 /torrent,它就再也找不到它了:404 Not Found。
复制步骤:
- 申请以下 yaml
helm install nginx ingress-nginx/ingress-nginx
- 转到
service_ip:8080
,设置,WebUI,取消选中“启用主机标头验证” - 去
localhost:nginx_port/torrent
结果:
- 页面未加载
预期结果:
- qBitTorrent WebUi 出现并运行
我尝试了什么:
- 添加
nginx.ingress.kubernetes.io/rewrite-target: /
到注释
服务器.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: torrent-deployment
labels:
app: torrent
spec:
replicas: 1
selector:
matchLabels:
pod-label: torrent-pod
template:
metadata:
labels:
pod-label: torrent-pod
spec:
containers:
- name: linuxserver
image: linuxserver/qbittorrent:amd64-latest
---
apiVersion: v1
kind: Service
metadata:
name: torrent-service
labels:
app: torrent
spec:
selector:
pod-label: torrent-pod
ports:
- port: 8080
name: torrent-deployment
ingress.yaml:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: torrent-ingress
annotations:
kubernetes.io/ingress.class: nginx
labels:
app: torrent
spec:
rules:
- http:
paths:
- path: /torrent
pathType: Prefix
backend:
service:
name: torrent-service
port:
number: 8080
解决方案
感谢@matt_j,我找到了解决方法。我自己为 nginx 编写了 YAML,并添加了 matt 提到的帖子中的配置(https://github.com/qbittorrent/qBittorrent/wiki/NGINX-Reverse-Proxy-for-Web-UI)并且它起作用了。
这些是我想出的 YAML:
服务器.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
namespace: nginx
spec:
selector:
matchLabels:
pod-label: nginx
template:
metadata:
labels:
pod-label: nginx
spec:
containers:
- name: nginx
image: nginx:latest
volumeMounts:
- name: nginx-conf
mountPath: /etc/nginx/
volumes:
- name: nginx-conf
configMap:
name: nginx-conf
items:
- key: nginx.conf
path: nginx.conf
replicas: 1
# status:
---
apiVersion: v1
kind: Service
metadata:
namespace: nginx
name: nginx
labels:
app: nginx
spec:
selector:
pod-label: nginx
ports:
- port: 80
name: nginx
配置.yaml:
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-conf
namespace: nginx
data:
nginx.conf: |
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
http {
server {
server_name 10.152.183.95;
listen 80;
location /torrent/ {
proxy_pass http://torrent-service.qbittorrent:8080/;
#proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
#proxy_cookie_path / "/; Secure";
}
}
}
events {
worker_connections 1024;
}
推荐阅读
- animation - 尝试使用 julialang 渲染动画时出错
- node.js - 具有更高数字的 TensorFlow 训练机器人抛出 NaN
- blazor-server-side - 带有 IStringLocalizer 的 Blazor 服务器端本地化未采用正确的资源文件
- javascript - Express-validator bail() 函数与 jest bail() 函数冲突
- java - 在数据集中显示小数
- javascript - 如果我传递序列化的 json 数据,它会出现在 http 请求中的什么位置?
- python - 如何将分类报告和混淆矩阵的输出导出为pdf或excel文件
- linux - 如何在 Linux 中查看用户的空闲时间?
- node.js - 在 NodeJS 中将背景图像添加到现有 PDF
- reactjs - 理解 Svelte 中的上下文(从 React 上下文转换)