HTTP directives

add_header directive (HTTP)

In http, server, location or if in location. No default field. Without always, applies to 200, 201, 204, 206, 301, 302, 303, 304, 307 and 308 on modern releases. always since 1.7.5. Under default inheritance, a child list replaces the parent list when defined; add_header_inherit is available since 1.29.3.

Formal Syntax & Structure

nginx syntaxnginx
add_header name value [always];

Parameters & Attributes

NameTypeDescription
namefield nameResponse field name.
valuestringField value, optionally containing variables.
alwayskeywordInclude field regardless of response code.

Working Example

Example Snippetnginx
add_header X-Lab-Chapter 6 always;
Nginx Reference