http-push-stream #
Long-polling / EventSource / WebSocket Pub-Sub server — turns nginx into a real-time message broker with channels, statistics and subscriber management.
Source: upstream source
Directives
push_stream_allow_connections_to_events_channel #
syntax: push_stream_allow_connections_to_events_channel 1 arg (on/off flag); · context: http, server, location, location-if
Boolean directive — set to "on" or "off".
push_stream_allowed_origins #
syntax: push_stream_allowed_origins 1 arg; · context: http, server, location
Sets Access-Control-Allow-Origin header values permitted for cross-domain publisher/subscriber requests.
push_stream_channel_deleted_message_text #
syntax: push_stream_channel_deleted_message_text 1 arg (string); · context: http
Stores a single string value.
push_stream_channel_inactivity_time #
syntax: push_stream_channel_inactivity_time 1 arg (duration in seconds); · context: http
Duration in seconds; accepts s / m / h / d suffixes.
push_stream_channel_info_on_publish #
syntax: push_stream_channel_info_on_publish 1 arg (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
push_stream_channels_path #
syntax: push_stream_channels_path 1 arg; · context: http, server, location, location-if
Location directives
push_stream_channels_statistics #
syntax: push_stream_channels_statistics no args; · context: location
Designates a location returning statistics for one, a group, or all channels.
push_stream_events_channel_id #
syntax: push_stream_events_channel_id 1 arg (string); · context: http
Stores a single string value.
push_stream_header_template #
syntax: push_stream_header_template 1 arg (string); · context: http, server, location
Stores a single string value.
push_stream_header_template_file #
syntax: push_stream_header_template_file 1 arg; · context: http, server, location
Reads a file once at startup whose content is sent to subscribers when they connect.
push_stream_last_event_id #
syntax: push_stream_last_event_id 1 arg; · context: http, server, location, location-if
Passes the last event id so the server knows which messages to resend to a subscriber.
push_stream_last_received_message_tag #
syntax: push_stream_last_received_message_tag 1 arg; · context: http, server, location, location-if
Passes the last received message tag so the server knows which messages to resend.
push_stream_last_received_message_time #
syntax: push_stream_last_received_message_time 1 arg; · context: http, server, location, location-if
Passes the last received message time so the server knows which messages to resend.
push_stream_longpolling_connection_ttl #
syntax: push_stream_longpolling_connection_ttl 1 arg (duration in ms); · context: http, server, location
Duration in milliseconds; accepts ms / s / m suffixes.
push_stream_max_channel_id_length #
syntax: push_stream_max_channel_id_length 1 arg (integer); · context: http
Integer value.
push_stream_max_messages_stored_per_channel #
syntax: push_stream_max_messages_stored_per_channel 1 arg (integer); · context: http
Integer value.
push_stream_max_number_of_channels #
syntax: push_stream_max_number_of_channels 1 arg (integer); · context: http
Integer value.
push_stream_max_number_of_wildcard_channels #
syntax: push_stream_max_number_of_wildcard_channels 1 arg (integer); · context: http
Integer value.
push_stream_max_subscribers_per_channel #
syntax: push_stream_max_subscribers_per_channel 1 arg (integer); · context: http
Integer value.
push_stream_message_template #
syntax: push_stream_message_template 1 arg (string); · context: http, server, location
Stores a single string value.
push_stream_message_ttl #
syntax: push_stream_message_ttl 1 arg (duration in seconds); · context: http
Duration in seconds; accepts s / m / h / d suffixes.
push_stream_padding_by_user_agent #
syntax: push_stream_padding_by_user_agent 1 arg (string); · context: http, server, location
Stores a single string value.
push_stream_ping_message_interval #
syntax: push_stream_ping_message_interval 1 arg (duration in ms); · context: http, server, location
Duration in milliseconds; accepts ms / s / m suffixes.
push_stream_ping_message_text #
syntax: push_stream_ping_message_text 1 arg (string); · context: http
Stores a single string value.
push_stream_publisher #
syntax: push_stream_publisher no args; · context: location
Designates a location as a publisher accepting messages to broadcast to subscribers.
push_stream_store_messages #
syntax: push_stream_store_messages 1 arg (on/off flag); · context: http, server, location, location-if
Boolean directive — set to "on" or "off".
push_stream_subscriber #
syntax: push_stream_subscriber no args; · context: location
Designates a location as a subscriber interface to a channel's message queue.
push_stream_subscriber_connection_ttl #
syntax: push_stream_subscriber_connection_ttl 1 arg (duration in ms); · context: http, server, location
Duration in milliseconds; accepts ms / s / m suffixes.
push_stream_timeout_with_body #
syntax: push_stream_timeout_with_body 1 arg (on/off flag); · context: http
Boolean directive — set to "on" or "off".
push_stream_user_agent #
syntax: push_stream_user_agent 1 arg; · context: http, server, location
Specifies where to read the user agent used for padding validation, replacing the User-Agent header.
push_stream_websocket_allow_publish #
syntax: push_stream_websocket_allow_publish 1 arg (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
push_stream_wildcard_channel_max_qtd #
syntax: push_stream_wildcard_channel_max_qtd 1 arg (integer); · context: http, server, location
Integer value.
push_stream_wildcard_channel_prefix #
syntax: push_stream_wildcard_channel_prefix 1 arg (string); · context: http
Stores a single string value.
Example
http {
push_stream_shared_memory_size 32M;
server {
location /pub {
push_stream_publisher admin;
push_stream_channels_path $arg_id;
}
location ~ /sub/(.+) {
push_stream_subscriber long-polling;
push_stream_channels_path $1;
push_stream_message_template "<script>parent.s({~text~});</script>";
}
}
}