CodexBloom - Programming Q&A Platform

Kubernetes Ingress Not Routing Traffic Correctly with Custom Annotations in NGINX Controller

๐Ÿ‘€ Views: 0 ๐Ÿ’ฌ Answers: 1 ๐Ÿ“… Created: 2025-08-07
kubernetes nginx ingress yaml

I'm facing an issue where my Kubernetes Ingress resource is not routing traffic as expected when using custom annotations with the NGINX Ingress Controller. I have defined an Ingress resource to route traffic to multiple services based on subdomains, but it seems to be ignoring the annotations I've set for SSL redirection and rewrite-target. Hereโ€™s my Ingress manifest: ```yaml apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: my-ingress annotations: nginx.ingress.kubernetes.io/ssl-redirect: "true" nginx.ingress.kubernetes.io/rewrite-target: /$2 spec: rules: - host: app.example.com http: paths: - path: /app/(.*) pathType: Prefix backend: service: name: app-service port: number: 80 - host: api.example.com http: paths: - path: /api/(.*) pathType: Prefix backend: service: name: api-service port: number: 80 ``` When I access `http://app.example.com/app/test`, it should redirect to `https://app.example.com/app/test`, but it doesnโ€™t. Also, I expected the path to be rewritten correctly, but it retains the `/app/` prefix in the routing. Iโ€™ve double-checked that the NGINX Ingress Controller is running properly and I can see it pick up the Ingress resource. I've also verified that the annotations are applied by checking the Ingress details with `kubectl describe ingress my-ingress`. The relevant part of the output shows: ``` Annotations: nginx.ingress.kubernetes.io/ssl-redirect: true nginx.ingress.kubernetes.io/rewrite-target: /$2 ``` Iโ€™m using NGINX Ingress Controller version 1.0.0. I tried removing and re-adding the Ingress resource, as well as restarting the Ingress Controller pods, but to no avail. I would appreciate any insights on why the routing might not be working as intended or any additional troubleshooting steps I could take. This is part of a larger API I'm building. I'd really appreciate any guidance on this.