Skip to content

proxy_intercept_errors off parameter does not work for me on nginx 404 response code #12430

Open
@jurajnovotny

Description

Hello, I am trying to extend a bit our configuration of ingress by adding server-snippet config under controller.config.server-snippet. The goal is to add 1 extra header to the all responses coming directly from NGINX.

So far I have it like that: (I know I can simplify it by putting it together)

controller
  config: 
    server-snippet: |
        error_page 503 @custom_503;
        error_page 404 @custom_404;
  
        proxy_intercept_errors off;
        
        location @custom_503 {
          internal;
          set $operation_id $request_id;
          add_header NGINX $operation_id always;
          return 503;
        }
  
        location @custom_404 {
          internal;
          set $operation_id $request_id;
          add_header NGINX $operation_id always;
          return 404;
        }

The 503 seems to work so far, but 404 part does not work at all when proxy_intercept_errors is set to OFF. Even on the ones that are 100% from NGINX. When I turn it on, it works, but it put that extra header on every single response, even on the ones that are not from NGINX.

I understand proxy_intercept_errors parameter as parameter that separates managing responses that comes directly from NGINX and the others.

So am I missing something or should I look at 404 response differently than at the 503?

Thank you so much !

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.needs-kindIndicates a PR lacks a `kind/foo` label and requires one.needs-priorityneeds-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions