[英]Kubernetes Nginx Ingress pod subpath
I have a pod that exposes an HTTP service.我有一个暴露 HTTP 服务的 pod。
This pod has some HTTP endpoints which are available under /accounts
.这个 pod 有一些 HTTP 端点,可以在
/accounts
。
My goal is to access this sub-path via accounts.example.com
.我的目标是通过
accounts.example.com
访问这个子路径。
For example if the url accounts.example.com/test
is requested, the nginx ingress should route the request to /accounts/test
on my pod.例如,如果请求 url
accounts.example.com/test
入口应该将请求路由到我的 pod 上的/accounts/test
。
In the nginx ingress documentation I cannot find a use-case with examples like this.在 nginx 入口文档中,我找不到包含此类示例的用例。
You should use rewrite to accomplish your request.您应该使用重写来完成您的请求。
https://kubernetes.github.io/ingress-nginx/examples/rewrite/https://kubernetes.github.io/ingress-nginx/examples/rewrite/
path: /something(/|$)(.*)
path: /something(/|$)(.*)
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: rewrite
namespace: default
spec:
rules:
- host: rewrite.bar.com
http:
paths:
- backend:
serviceName: http-svc
servicePort: 80
path: /something(/|$)(.*)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.