I have a simple ingress configuration file-
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /link2/link3/
name: tut-ingress
namespace: default
spec:
rules:
- host: tutorial.com
http:
paths:
- path: /link1/
pathType: Prefix
backend:
service:
name: nginx-ingress-tut-service
port:
number: 8080
in which requests coming to /link1 or /link1/ are rewritten to
/link2/link3/.
When I access it using http://tutorial.com/link1/
I am shown the correct result but when I access it using
http://tutorial.com/link1, I get a 404 not found.
The nginx-ingress-tut-service has the following endpoints-
//link1/link2/link3
I am a beginner in the web domain, any help will be appreciated.
When I change it to-
- path: /link1
it starts working fine, but can anybody tell why is it not working with /link1/.
Helpful resources - https://kubernetes.io/docs/concepts/services-networking/ingress/#examples
https://kubernetes.github.io/ingress-nginx/examples/rewrite/
Edit- Please also explain what happens when you write a full HTTP link in
nginx.ingress.kubernetes.io/rewrite-target