I'm running an application on kubernetes, when i use this url: https://myapp.test.com/ it redirects me to ressource not found (problem in the application). what i need now is to avoid this page by redirecting the url/ to url/test where i have the home page of the application. Is this possible using Ingress? If you can show me please an example of a configuration that does this redirection. Thank you.
1 Answer
Add an annotation nginx.ingress.kubernetes.io/app-root: /test as per the documentation kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root
Quoted from the doc and adapted to your exemple, your ingress yaml should look like this (adapt the target service and port):
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/app-root: /test
name: myapp
namespace: default
spec:
ingressClassName: nginx
rules:
- host: myapp.test.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: http-svc
port:
number: 80