I have a pod that exposes an HTTP service.
This pod has some HTTP endpoints which are available under /accounts
.
My goal is to access this sub-path via 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.
In the nginx ingress documentation I cannot find a use-case with examples like this.
You should use rewrite to accomplish your request.
https://kubernetes.github.io/ingress-nginx/examples/rewrite/
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(/|$)(.*)