I have the following ingress controller and the host that contains api answers to this url https://api.example.com/docs.
Now I would like to configure this nginx ingress access the /docs endpoint using https://docs.example.com. I have tried to use the annotation rewrite-target but I can't figure out how to accomplish this.
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: api-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
kubernetes.io/ingress.class: nginx
certmanager.k8s.io/acme-challenge-type: dns01
certmanager.k8s.io/cluster-issuer: letsencrypt
spec:
rules:
- host: example.com
http:
paths:
- path: /
backend:
serviceName: web-service
servicePort: 80
- host: api.example.com
http:
paths:
- path: /
backend:
serviceName: api-service
servicePort: 80
tls:
- hosts:
- example.com
secretName: example.comWhat you need here is the app-root annotation. If you use something like this:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/app-root: /docsincoming requests at example.com/ will be rewritten internally to example.com/docs.
Please let me know if that helped.