Exclude specific hosts from ssl redirect in Kubernetes Nginx Ingress
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
Ingress-wide SSL redirect is useful for security, but sometimes one host must remain on HTTP for legacy integrations or controlled internal traffic. In NGINX Ingress, redirect behavior is mostly annotation-driven, and annotations apply per Ingress resource, not per host rule. The clean workaround is splitting hosts across separate Ingress objects.
Understand Redirect Scope in NGINX Ingress
A common annotation is nginx.ingress.kubernetes.io/ssl-redirect. When set to true, HTTP requests are redirected to HTTPS. The important detail is scope: annotation behavior affects the whole Ingress resource.
If one Ingress contains both secure and non-secure hosts, selective per-host redirect is difficult and often brittle. Splitting into two resources gives explicit control and clearer intent.
Configure Secure and Non-Secure Hosts Separately
Use one Ingress for hosts that must redirect and another for hosts that should stay on HTTP.
This approach keeps intent explicit and easy to reason about during audits.
Validate Behavior After Deployment
After applying manifests, verify each host independently.
Expected result:
secure.example.comreturns redirect status to HTTPSinsecure.example.comresponds directly on HTTP without redirect
If behavior differs, inspect effective NGINX configuration and controller logs.
Optional: Force Redirect on Path Basis With Snippets
Some teams attempt path-level custom rules using snippet annotations. This can work, but it increases operational complexity and may conflict with controller security settings that disable snippets.
Prefer separate Ingress resources first. Use snippets only when architecture constraints make split resources impossible.
Security and Operational Considerations
Hosts excluded from SSL redirect should be intentionally documented and reviewed regularly. If plaintext traffic is allowed, define network boundaries and monitoring expectations clearly.
Recommended controls:
- restrict insecure host exposure with source IP allow lists
- run periodic checks that insecure hosts remain intentional
- log and alert on unexpected traffic patterns
- keep deprecation timeline for legacy HTTP dependencies
Exclusions should be treated as temporary exceptions whenever possible.
Common Pitfalls
- Trying to configure host-specific redirect behavior inside one Ingress resource only.
- Forgetting that annotations usually apply at resource scope, not host-rule scope.
- Defining TLS for an insecure host accidentally, which can trigger redirect side effects.
- Skipping post-deploy verification and assuming annotation changes applied as intended.
- Allowing permanent HTTP exceptions without documented risk ownership.
Summary
- SSL redirect annotations are generally applied per Ingress resource.
- To exclude specific hosts, split secure and non-secure hosts into separate Ingress objects.
- Validate each host with explicit HTTP checks after deployment.
- Use snippet-based overrides only when split resources are not feasible.
- Treat HTTP exceptions as controlled, reviewed risk decisions.
- Keep separate ownership and review approval for insecure-host manifests in production clusters.
- Add continuous HTTP probes to detect accidental redirect policy changes after controller upgrades.
- Use namespace labels and policy checks so insecure ingress resources are easy to inventory.
- Revisit exception necessity regularly and migrate legacy clients to HTTPS when possible.

