push_stream_header_template

The push_stream_header_template directive specifies the custom header template for push stream responses.

Syntaxpush_stream_header_template template_string;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The push_stream_header_template directive is a configuration parameter used in the NGINX Push Stream Module, allowing users to define a template for the headers that are sent with push stream responses. It can be specified in the http, server, or location contexts and modifies how the headers are formatted based on the defined template.

This directive takes a single argument, which is the header template string. Placeholders in the template can include variables such as channel IDs or message data, enabling dynamic content to be injected into the headers of the push stream messages. The configuration allows developers to customize the client-side experience, particularly in real-time applications where the structure of the data being sent is crucial.

When this directive is set, it modifies outgoing HTTP headers according to the template specified. If not defined, NGINX will use a default behavior that may not include the desired formatting or necessary metadata for the push notifications. Users should ensure that their templates are correctly formatted and tested to avoid runtime errors related to incorrect header formats.

Config Example

http {
    push_stream_header_template "Custom-Header: {channel_id} {message}";
}

Ensure that the template string is correctly formatted to avoid syntax errors.

Be cautious with user input in header templates to prevent header injection vulnerabilities.

Test the behavior in both subscriber and publisher contexts to confirm expected header outputs.

← Back to all directives