My issue: The snippets “add_header“ doesn’t show/works with all ingress applications
How I encountered the problem: I’m installing NGINX Ingress Controller Community as an alternative to Ingress-Nginx, I’m testing Ingress annotations and needed to add a header for example to enable CORS u other value.
Solutions I’ve tried:
- Trying with annotations “nginx.org/server-snippets” or “nginx.org/location-snippets”.
- Copying the success case and the error case from the same Ingress base.
- Install from other chart version 2.4.0
Version of NIC and/or NGINX: helm chart nginx-ingress-2.4.3, app version 5.3.3 and kubernetes 1.34.2
Deployment environment:
Install with helm:
helm install nginx-ingress oci://ghcr.io/nginx/charts/nginx-ingress \
--version 2.4.3 \
--set controller.service.type=NodePort \
--set controller.service.externalTrafficPolicy=Local \
--set controller.hostNetwork=true \
--set controller.kind=daemonset \
--set controller.enableCustomResources=true \
--set controller.wildcardTLS.secret=default/my-ssl \
--set controller.defaultTLS.secret=default/my-ssl \
--set controller.enableSnippets=true
1 ) Success case
Ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.org/server-snippets: |
add_header my-test-header test-value;
name: nginx-prod
namespace: default
spec:
ingressClassName: nginx
rules:
- host: nginx-prod.mysite.com
http:
paths:
- backend:
service:
name: nginx-prod
port:
number: 8080
path: /
pathType: ImplementationSpecific
tls:
- hosts:
- nginx-prod.mysite.com
secretName: my-ssl
Example curl
curl https://nginx-prod.mysite.com --head
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 Feb 2026 18:18:30 GMT
Content-Type: text/html
Content-Length: 615
Connection: keep-alive
Last-Modified: Wed, 04 Feb 2026 15:12:20 GMT
ETag: "698361d4-267"
Accept-Ranges: bytes
my-test-header: test-value --> Correct
- Error case
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
annotations-risk-level: Critical
nginx.org/location-snippets: |
add_header my-test-header test-value;
name: app1
namespace: default
spec:
ingressClassName: nginx
rules:
- host: app1.mysite.com
http:
paths:
- backend:
service:
name: app1
port:
number: 3000
path: /
pathType: ImplementationSpecific
tls:
- hosts:
- app1.mysite.com
secretName: my-ssl
Example curl
curl https://app1.mysite.com --head
HTTP/1.1 404 Not Found -> Real reply from my app1 because need more data
Server: nginx
Date: Fri, 13 Feb 2026 18:28:38 GMT
Content-Type: text/html
Content-Length: 146
Connection: keep-alive
NOTE: I know is not the same, but with ingress-nginx app1 . mysite . com it works correctly.
HTTP/1.1 404 Not Found
Date: Fri, 13 Feb 2026 18:33:04 GMT
Connection: keep-alive
Vary: Origin
Strict-Transport-Security: max-age=31536000; includeSubDomains
my-test-header: test-value --> Correct