# Snippets add\_header doesn't work with all applications

**URL:** <https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034>\
**Category:** NGINX Ingress Controller\
**Tags:** config, web-server\
**Created:** [February 13, 2026, 6:45pm UTC](https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034 "2026-02-13T18:45:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VictorCisternas](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/victorcisternas/32/4146_2.png) [@VictorCisternas](https://community.nginx.org/u/VictorCisternas)\
**Post date:** [February 13, 2026, 6:45pm UTC](https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034/1 "2026-02-13T18:45:10Z")

</div>

**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”](http://nginx.org/server-snippets%E2%80%9D) or “[nginx.org/location-snippets”](http://nginx.org/location-snippets%E2%80%9D).
- 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:

```auto
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

```auto
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

```auto
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

```

1. Error case

```auto
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

```auto
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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![Micheal\_Kingston](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/micheal_kingston/32/3810_2.png) [@Micheal\_Kingston](https://community.nginx.org/u/Micheal_Kingston)\
**Post date:** [February 13, 2026, 7:07pm UTC](https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034/2 "2026-02-13T19:07:39Z")

</div>

Hi @VictorCisternas !

I think the issue here is inheritance. Could you try this? [Module ngx\_http\_headers\_module](https://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header_inherit)

---

<div class="post-metadata">

**Author:** ![VictorCisternas](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/victorcisternas/32/4146_2.png) [@VictorCisternas](https://community.nginx.org/u/VictorCisternas)\
**Post date:** [February 13, 2026, 10:31pm UTC](https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034/3 "2026-02-13T22:31:34Z")

</div>

@Micheal_Kingston Thank you, in the documentation you sent me, I understand that it may be because the application is responding with a 404 code and add\_header supports other codes.

Anyway, perform the tests without changes:

```auto
    nginx.org/server-snippets: |
      add_header_inherit merge;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_header_inherit on;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_header_inherit off;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_trailer_inherit merge;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_trailer_inherit on;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_trailer_inherit off;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_header_inherit merge;
      add_trailer_inherit merge;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_header_inherit on;
      add_trailer_inherit on;
      add_header Access-Control-Allow-Origin *;
or:
    nginx.org/server-snippets: |
      add_header_inherit off;
      add_trailer_inherit off;
      add_header Access-Control-Allow-Origin *;

```

Now I understand the cause, I’ll try to run some more tests, thanks!!

---

<div class="post-metadata">

**Author:** ![system](https://drob5swvtjqxg.cloudfront.net/user_avatar/community.nginx.org/system/32/19_2.png) [@system](https://community.nginx.org/u/system)\
**Post date:** [February 20, 2026, 10:32pm UTC](https://community.nginx.org/t/snippets-add-header-doesnt-work-with-all-applications/9034/4 "2026-02-20T22:32:15Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
