To send custom HTTP headers with Nginx, you can use the add_header
directive in the server
block of your Nginx configuration file. This directive allows you to specify additional HTTP headers that should be included in the response sent to clients.
Here's an example of how you can use the add_header
directive to send a custom HTTP header with Nginx:
server { # Your server block directives go here # Add a custom HTTP header to the response add_header X-Custom-Header "Custom header value"; }
In this example, the add_header
directive adds a custom HTTP header called X-Custom-Header
to the response, with the value "Custom header value".
You can specify multiple add_header
directives in a single server
block to add multiple custom HTTP headers to the response. You can also use the always
parameter to ensure that the header is always sent, even if the response code is not 2xx or 3xx.
For more information on the add_header
directive and other ways to send custom HTTP headers with Nginx, you can refer to the Nginx documentation.