I am using nginx ingress controller in my k8s cluster, with AWS L4 NLB with SSL Redirection based on this documentation: https://github.com/helm/charts/tree/master/stable/nginx-ingress#aws-l4-nlb-with-ssl-redirection
My website is multi-tenant: subdomain.domain.com. Since some limitations, we need to redirect requests from my main page subdomain.domain.com to subdomain.domain.com/app
But ONLY the root url and not any other paths.
For example:
only
subdomain.domain.com goes to subdomain.domain.com/app
but
subdomain.domain.com/api/v1 stays on subdomain.domain.com/api/v1
Any way to do this using server-snippet redirect rules? or should I consider other options? like a backend service etc…
Thanks!
2
Answers
You’ll want to use a Path type to match where you want to send traffic.
Also, you’re pointing to a deprecated chart; the maintained and up-to-date chart is at https://github.com/kubernetes/ingress-nginx/tree/main/charts/ingress-nginx.
You can set up redirects with annotations or send / straight to what /app service
In the values.yaml
controller.annotations
Or use the AWS NLB static chart that has it setup already
https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.5.1/deploy/static/provider/aws/nlb-with-tls-termination/deploy.yaml
https://kubernetes.io/docs/concepts/services-networking/ingress/#path-types
You can use annotations app-root. Please refer this link: https://kubernetes.github.io/ingress-nginx/examples/rewrite/#app-root