push_stream_channels_path

The `push_stream_channels_path` directive sets the channel path for subscribing and publishing in the NGINX Push Stream Module.

Syntaxpush_stream_channels_path value;
Defaultnone
Contexthttp, server, location, if in location
Arguments1

Description

The push_stream_channels_path directive is used in the NGINX Push Stream Module to define the channel path for publishing or subscribing to messages. It can accept either a positional argument or query string argument to dynamically configure the channel path based on the request. This capability is particularly useful when creating a scalable real-time web application, as it allows multiple channels to be handled seamlessly. When specified, NGINX processes the associated location block, extracting the channel identifier from the request and using it to manage the communication between publishers and subscribers.

In the context of a location block, this directive can utilize both static and dynamic values to represent channels. For example, using $arg_id as the argument parses the channel ID from the query string, making it easy to publish and subscribe to different channels based on user input. If the directive is placed in a regex location, it can capture the specified segment from the URL as the channel name. This flexibility enhances the capability to support many concurrent subscribers by managing individual streams effectively without the need for unique locations for every channel.

In summary, push_stream_channels_path is an essential directive for setting the channel paths within your NGINX configuration, streamlining message routing in real-time applications by enabling flexible channel management via HTTP requests.

Config Example

server {
    location /pub {
        push_stream_publisher admin;
        push_stream_channels_path $arg_id;
    }
    location /sub/(.*) {
        push_stream_subscriber;
        push_stream_channels_path $1;
    }
}

Ensure the directive is correctly placed within a server or location context; otherwise, it will not be effective.

If used improperly, such as conflicting path parameters, it may result in the system not identifying the correct channels consistently.

Dynamic channel paths may lead to performance considerations if not adequately handled, especially under high load.

← Back to all directives