How do you do path-based rewrite for an app that expects to be served from `/`?
IntermediateScenarioServices, Ingress and DNS
Answer
Situation read → You expose /shop but the app serves assets from /.
What I'd do →
- With ingress-nginx use
nginx.ingress.kubernetes.io/rewrite-target: /$2and path/shop(/|$)(.*)withpathType: ImplementationSpecific - Better, configure the app base path
- Check redirects and absolute asset URLs
- Test with
curl -I - Consider a subdomain instead of paths
Why → Rewriting handles incoming paths but not links generated by the app, so base-path support in the app is cleaner.
Interview tip → Say you prefer subdomains to avoid path rewriting complexity.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate