[英]kubernetes nginx ingress subpath to subdomain redirection
我正在嘗試實現以下 proxy_pass 設置,基本上其中一項服務是列出 subdomain.example.com/guacamole 但我想將其作為 subdomain.example.com 提供
location / {
proxy_pass http://guacamole:8080/guacamole/;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_cookie_path /guacamole/ /;
access_log off;
# allow large uploads (default=1m)
# 4096m = 4GByte
client_max_body_size 4096m;
}
下面是nginx入口
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: guacamole-ingress
annotations:
kubernetes.io/ingress.class: nginx
spec:
tls:
- hosts:
- subdomain.example.com
rules:
- host: subdomain.example.com
http:
paths:
- path: /guacamole
backend:
serviceName: service-guacamole-frontend
servicePort: 8080
我嘗試使用nginx.ingress.kubernetes.io/rewrite-target: /
但它沒有用。
更換path: /guacamole
與path: /
應該做的伎倆。
rules:
- host: subdomain.example.com
http:
paths:
- path: / # replace `/guacamole` with `/`
backend:
serviceName: service-guacamole-frontend
servicePort: 8080
您應該使用app-root
注釋。
來自 nginx-ingress 文檔:
如果Application Root暴露在不同的路徑,需要重定向,設置注解nginx.ingress.kubernetes.io/app-root重定向/請求。
嘗試使用:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: guacamole-ingress
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/app-root: /guacamole
spec:
tls:
- hosts:
- subdomain.example.com
rules:
- host: subdomain.example.com
http:
paths:
- path: /
backend:
serviceName: service-guacamole-frontend
servicePort: 8080
在這里你可以找到另一個例子。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.