on portforwading the svc & ingress to localhost, everything works fine.
with public IP from svc & nginx ingress, the frontend is reachable and works fine, only issue is it doesn’t route to the next page, while it does in localhost. where could this possible go wrong?
infra:
managed k8s: Azure AKS
frontend: react dockerized & served via nginx
ingress: nginx ingress controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- host: ""
http:
paths:
- path: /api(/|$)(.*)
pathType: ImplementationSpecific
backend:
service:
name: api-svc
port:
number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: frontend-ingress
namespace: default
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/use-regex: "true"
# nginx.ingress.kubernetes.io/rewrite-target: /$1
nginx.ingress.kubernetes.io/enable-modsecurity: "true"
nginx.ingress.kubernetes.io/enable-owasp-modsecurity-crs: "true"
spec:
ingressClassName: nginx
rules:
- host: ""
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: frontend-app-svc
port:
number: 80
- NSG is fine from AKS
- localhost portforwading of frontend works fine, but only routing is not happening from public ip of svc & ingress
- backend svc works fine in all cases
- tried to get to the exact path after login, but it doesn’t work
- tried to kill everything and redo
- several retries with ingress rules
This is solved, posting this answer if this helps anyone.
the root cause is, if localhost portforwading works fine, and the domain doesn’t, possibly it’d be because of the following,
- check NSG rules for the ip
- check if there any hostnames list on your application level, ie, allow API only if the request is from the defined ip, or route only from the defined lists
- remove ingress rules, and try verifying on svc level, so to verify if it’s path issue or application-level issue
mostly these helped me to find the root cause, in my case, application had allowedHostnames
list and auth routing would only work if the ip is from this list.