如何解决kubernetes nginx到子域重定向的入口子路径
我正在尝试实现以下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
,
您应该使用Keychain
批注。
来自nginx-ingress docs:
如果“应用程序根目录”位于其他路径中,并且需要重定向,请设置注释nginx.ingress.kubernetes.io/app-root以重定向对/的请求。
尝试使用:
keychain["isPremium"] = "true" // set the state
let token = try? keychain.get("isPremium") // get the state to check if it worked
print(token as Any)
Here,您可以找到另一个示例。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。