kubernetes nginx入口子路径到子域重定向
我正在尝试实现下面的代理权限设置,基本上其中一个服务正在subdomain.example.com/guacamole中列出,但我想将其作为subdomain.example.com提供kubernetes nginx入口子路径到子域重定向,nginx,kubernetes,nginx-ingress,guacamole,Nginx,Kubernetes,Nginx Ingress,Guacamole,我正在尝试实现下面的代理权限设置,基本上其中一个服务正在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
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.ingres.kubernetes.io/rewrite-target://
,但没有成功。用路径://
替换路径:/guacamole
应该可以
规则:
-主机:subdomain.example.com
http:
路径:
-路径:/#将`/guacamole`替换为`/`
后端:
serviceName:服务鳄梨酱前端
服务端口:8080
用path://
替换path:/guacamole
,应该可以解决这个问题
规则:
-主机:subdomain.example.com
http:
路径:
-路径:/#将`/guacamole`替换为`/`
后端:
serviceName:服务鳄梨酱前端
服务端口:8080
您应该使用应用程序根目录
注释
从nginx入口:
如果应用程序根暴露在不同的路径中,需要重定向,请将注释nginx.ingres.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
您可以找到另一个示例。您应该使用
approot
注释
从nginx入口:
如果应用程序根暴露在不同的路径中,需要重定向,请将注释nginx.ingres.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
您可以找到另一个示例。此配置正在重定向到subdomain.example.com/guacamole,而不是subdomain.example.com,这是主要的moto。@RahulSharma,请澄清您试图实现的目标。此配置正在重定向到subdomain.example.com/guacamole,而不是subdomain.example.com,哪一个是主moto。@RahulSharma,请澄清您试图实现的目标。此配置将重定向到subdomain.example.com/guacamole,而不是subdomain.example.com,这是主moto。此配置将重定向到subdomain.example.com/guacamole,而不是subdomain.example.com,这是主moto。