ngx_link_func_add_req_header

The ngx_link_func_add_req_header directive adds a specified HTTP request header to the context of an NGINX server configuration.

Syntaxngx_link_func_add_req_header header_name header_value;
Defaultnone
Contexthttp, server, location, if in location
Arguments2

Description

The ngx_link_func_add_req_header directive is used in the context of NGINX to facilitate the addition of custom HTTP request headers. It operates by accepting two parameters: the first is the name of the header to be added, while the second is the value assigned to that header. This directive makes it possible for any dynamic linking function or application in connection with NGINX to access these headers when processing incoming requests. It is particularly used in modules designed to enhance HTTP request processing with additional metadata, which can be utilized by linked functionalities.

When configuring this directive, you can place it within various contexts including http, server, location, and if within a location block. It is essential to use this directive correctly to ensure the intended headers are added as NGINX serves requests. Misconfiguration can lead to headers being omitted or incorrect values being sent, potentially affecting the upstream service's behavior or the response that end-users receive. Understanding the order of directives and their context will help in mastering the correct usage of this directive.

Config Example

server {
    listen 80;
    location /example {
        ngx_link_func_add_req_header "X-Custom-Header" "This is a custom header";
    }
}

Ensure that header names are valid and correctly formatted to adhere to HTTP standards.

Headers should be added in appropriate contexts to ensure they are sent with the right requests.

Be cautious when using dynamic values in headers as this can introduce unexpected behavior if not properly handled.

← Back to all directives