我对kubernetes nginx虚拟线路感到困惑。https://docs.nginx.com/nginx-ingress-controller/configuration/virtualserver-and-virtualserverroute-resources/#virtualserverroute-subroute
在前缀的情况下,路径必须与引用此资源的VirtualServer路由的路径相同
path: /coffee
action:
path: coffee/coffee会被传递给应用程序吗?
因为当我尝试使用该路由部署虚拟服务器时,它无法工作(例如下面的示例)
path: /one
action:
path: hellok8s但是,我以前使用的这条路径正在工作。
path: /
action:
path: hellok8s举个例子,如果我有一个app-1和app-2.我应该通过主机或子路径来区分它们吗?
或者有办法通过下面这样的路径来区分它们?
-编辑
apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
name: hellok8s-app-vs
spec:
host: helloworld.moonshot.com
tls:
secret: nginx-tls-secret
# basedOn: scheme
redirect:
enable: true
code: 301
upstream:
- name: hellok8s
service: hellok8s-service
port: 8080
routes:
- path: /one
action:
proxy:
upstream: hellok8s
rewritePath: /发布于 2021-04-28 09:58:48
因此,路径是URL,它将由Nginx向外部世界公开。该路径在内部发生了什么取决于操作的子属性,例如:
在这里,/coffee是最终用户所看到的,但是请求被发送到咖啡服务的根。因此,如果咖啡是运行在8080的K8S中的一个服务,请求将在coffee:8080登陆。
path: /coffee
action:
pass: coffee但是有更多的行为。假设您使用了action.proxy,那么您可以在更细粒度的级别上定义路径应该发生的情况。因此,在下面的示例中,我们将转发到coffee服务,但是请求路径正在重写到filtercoffee。
proxy:
upstream: coffee
rewritePath: /filtercoffee 您也可以使用重定向,返回操作的pass指令,但您必须使用使用这里列出的四个中的一个
https://stackoverflow.com/questions/67297121
复制相似问题