nchan #
<img class="logo" alt="NCHAN" src="https://nchan.io/github-logo.png" />
Source: upstream source
Directives
nchan_access_control_allow_credentials #
syntax: nchan_access_control_allow_credentials 1 arg (on/off flag); · context: http, server, location, location-if
Boolean directive — set to "on" or "off".
nchan_access_control_allow_origin #
syntax: nchan_access_control_allow_origin 1 arg; · context: http, server, location, location-if
Sets the CORS Access-Control-Allow-Origin header to the given value, defaulting to $http_origin.
nchan_benchmark #
syntax: nchan_benchmark no args; · context: location
Enables Nchan's built-in benchmark mode on a location, running as a websocket pub/sub benchmark handler.
nchan_benchmark_channels #
syntax: nchan_benchmark_channels 1 arg (integer); · context: location
Integer value.
nchan_benchmark_message_padding_bytes #
syntax: nchan_benchmark_message_padding_bytes 1 arg (integer); · context: location
Integer value.
nchan_benchmark_messages_per_channel_per_minute #
syntax: nchan_benchmark_messages_per_channel_per_minute 1 arg (integer); · context: location
Integer value.
nchan_benchmark_publisher_distribution #
syntax: nchan_benchmark_publisher_distribution 1 arg; · context: location
Sets how benchmark publishers are distributed across worker processes: random or optimal/best.
nchan_benchmark_subscriber_distribution #
syntax: nchan_benchmark_subscriber_distribution 1 arg; · context: location
Sets how benchmark subscribers are distributed across worker processes: random or optimal/best.
nchan_benchmark_subscribers_per_channel #
syntax: nchan_benchmark_subscribers_per_channel 1 arg (integer); · context: location
Integer value.
nchan_benchmark_time #
syntax: nchan_benchmark_time 1 arg (duration in seconds); · context: location
Duration in seconds; accepts s / m / h / d suffixes.
nchan_channel_event_string #
syntax: nchan_channel_event_string 1 arg; · context: server, location, location-if
Let's see what this channel events subscriber receives when I publish messages to Subscribing to /pubsub/foo produces the channel event Publishing a message to /pubsub/foo: Unsubscribing from /pubsub/foo: Deleting /pubsub/foo (with HTTP DELETE /pubsub/foo): The event string itself is configirable with nchan_channel_event_string.
nchan_channel_events_channel_id #
syntax: nchan_channel_events_channel_id 1 arg; · context: server, location, location-if
Sets the channel id, in the hardcoded 'meta' group, to which subscriber and publisher events are sent.
nchan_channel_group #
syntax: nchan_channel_group 1 arg; · context: server, location, location-if
(This can be ensured, as above, by setting separate nchan_channel_groups.).
nchan_channel_group_accounting #
syntax: nchan_channel_group_accounting 1 arg (on/off flag); · context: server, location
Can be set with nginx variables. - nchan_channel_group_accounting arguments: 1 default: off context: server, location > Enable tracking channel, subscriber, and message information on a per-channel-group basis.
nchan_channel_id #
syntax: nchan_channel_id 1 arg; · context: server, location, location-if
By default, it is set to $nchan_channel_event $nchan_channel_id.
nchan_channel_id_split_delimiter #
syntax: nchan_channel_id_split_delimiter 1 arg (string); · context: server, location, location-if
Stores a single string value.
nchan_channel_timeout #
syntax: nchan_channel_timeout 1 arg (duration in seconds); · context: http, server, location
This data does not account for information from other Nchan instances, and monitors only local connections, published messages, etc. more details - nchan_channel_timeout arguments: 1 context: http, server, location legacy name: push_channel_timeout > Amount of time an empty channel hangs around.
nchan_deflate_message_for_websocket #
syntax: nchan_deflate_message_for_websocket 1 arg; · context: server, location
Message deflation is enabled by setting the nchan_deflate_message_for_websocket on; directive in a publisher location. <br /> The deflated data is stored alongside the original message in memory, or, if large enough, on disk.
nchan_eventsource_event #
syntax: nchan_eventsource_event 1 arg (string); · context: server, location, location-if
Stores a single string value.
nchan_eventsource_ping_comment #
syntax: nchan_eventsource_ping_comment 1 arg; · context: server, location, location-if
When used in a subscriber location, overrides all messages' associated event: string with the given value. - nchan_eventsource_ping_comment arguments: 1 default: (empty) context: server, location, if > Set the EventSource comment : ... line for periodic pings from server to client.
nchan_eventsource_ping_data #
syntax: nchan_eventsource_ping_data 1 arg; · context: server, location, location-if
If empty, no comment is sent with the ping. - nchan_eventsource_ping_data arguments: 1 default: (empty) context: server, location, if > Set the EventSource data: line for periodic pings from server to client.
nchan_eventsource_ping_event #
syntax: nchan_eventsource_ping_event 1 arg; · context: server, location, location-if
If empty, no data is sent with the ping. - nchan_eventsource_ping_event arguments: 1 default: ping context: server, location, if > Set the EventSource event: line for periodic pings from server to client.
nchan_eventsource_ping_interval #
syntax: nchan_eventsource_ping_interval 1 arg (duration in seconds); · context: server, location, location-if
If empty, no event type is sent with the ping. - nchan_eventsource_ping_interval <number> (seconds) arguments: 1 default: 0 (none) context: server, location, if > Interval for sending ping messages to EventSource subscribers.
nchan_group_location #
syntax: nchan_group_location no args; · context: location
To get group data, send a GET request to a nchan_group_location: By default, the data is returned in human-readable plaintext, but can also be formatted as JSON, XML, or YAML: The data in the response are for the single Nchan instance only, regardless of whether Redis is used.
nchan_group_max_channels #
syntax: nchan_group_max_channels 1 arg; · context: location
Limits the maximum number of channels allowed in the group, defaulting to 0 (unlimited).
nchan_group_max_messages #
syntax: nchan_group_max_messages 1 arg; · context: location
Limits the maximum number of messages allowed across all channels in the group, defaulting to 0 (unlimited).
nchan_group_max_messages_disk #
syntax: nchan_group_max_messages_disk 1 arg; · context: location
Limits the maximum disk space allowed for messages across all channels in the group, defaulting to 0 (unlimited).
nchan_group_max_messages_memory #
syntax: nchan_group_max_messages_memory 1 arg; · context: location
Limits the maximum shared memory allowed for messages across all channels in the group, defaulting to 0 (unlimited).
nchan_group_max_subscribers #
syntax: nchan_group_max_subscribers 1 arg; · context: location
Limits the maximum number of subscribers allowed across all channels in the group, defaulting to 0 (unlimited).
nchan_longpoll_multipart_response #
syntax: nchan_longpoll_multipart_response 1 arg; · context: server, location, location-if
Disabled by default. - nchan_longpoll_multipart_response [ off | on | raw ] arguments: 1 default: off context: server, location, if > when set to 'on', enable sending multiple messages in a single longpoll response, separated using the multipart/mixed content-type scheme.
nchan_max_channel_id_length #
syntax: nchan_max_channel_id_length 1 arg (integer); · context: http, server, location
Integer value.
nchan_max_channel_subscribers #
syntax: nchan_max_channel_subscribers 1 arg (integer); · context: http, server, location
Integer value.
nchan_message_buffer_length #
syntax: nchan_message_buffer_length 1 arg; · context: http, server, location
Used for channel statistics, message storage, and interprocess communication. more details - nchan_store_messages [ on | off ] arguments: 1 default: on context: http, server, location, if legacy name: push_store_messages > Publisher configuration. "off" is equivalent to setting nchan_message_buffer_length 0, which disables the buffering of old messages.
nchan_message_temp_path #
syntax: nchan_message_temp_path 1 arg (filesystem path); · context: http
An Nginx variable can also be used to set the buffer length dynamically. - nchan_message_temp_path <path> arguments: 1 default: <client_body_temp_path> context: http > Large messages are stored in temporary files in the client_body_temp_path or the nchan_message_temp_path if the former is unavailable.
nchan_message_timeout #
syntax: nchan_message_timeout 1 arg; · context: http, server, location
Default is the built-in default client_body_temp_path - nchan_message_timeout [ <time> | <variable> ] arguments: 1 default: 1h context: http, server, location legacy name: push_message_timeout > Publisher configuration setting the length of time a message may be queued before it is considered expired.
nchan_permessage_deflate_compression_level #
syntax: nchan_permessage_deflate_compression_level 1 arg; · context: http
Sets the deflate compression level (0 no compression to 9 slowest-best) for the websocket permessage-deflate extension, defaulting to 6.
nchan_permessage_deflate_compression_memlevel #
syntax: nchan_permessage_deflate_compression_memlevel 1 arg; · context: http
Sets the memory level (1-9) allocated for the deflate algorithm's internal compression state, defaulting to 8.
nchan_permessage_deflate_compression_strategy #
syntax: nchan_permessage_deflate_compression_strategy 1 arg; · context: http
Sets the deflate compression strategy (default, filtered, huffman-only, rle, or fixed) used in the permessage-deflate extension, defaulting to default.
nchan_permessage_deflate_compression_window #
syntax: nchan_permessage_deflate_compression_window 1 arg; · context: http
Use 'default' for normal data, For details see zlib's section on copression strategies - nchan_permessage_deflate_compression_window [ 9-15 ] arguments: 1 default: 10 context: http > Compression window for the deflate algorithm used in websocket's permessage-deflate extension.
nchan_publisher #
syntax: nchan_publisher no args; · context: server, location, location-if
The bigger the window, the better the compression, but the more memory used by the compressor. - nchan_publisher [ http | websocket ] arguments: 0 - 2 default: http websocket context: server, location, if legacy name: push_publisher > Defines a server or location as a publisher endpoint.
nchan_publisher_channel_id #
syntax: nchan_publisher_channel_id 1 arg; · context: server, location, location-if
Sets the channel id or ids (up to several values) for a publisher location.
nchan_publisher_upstream_request #
syntax: nchan_publisher_upstream_request 1 arg; · context: server, location, location-if
Messages received with this subprotocol are of the form <pre> id: message_id content-type: message_content_type \n message_data </pre> The content-type: line may be omitted. <br /> #### Websocket Publisher Messages published through a websocket connection can be forwarded to an upstream application with the nchan_publisher_upstream_request config directive.
nchan_pubsub #
syntax: nchan_pubsub no args; · context: server, location, location-if
Unlike the other subscriber types, the chunked subscriber cannot be used with http/2 because it disallows chunked encoding. <!-- tag:subscriber-chunked --> ## PubSub Endpoint PubSub endpoints are Nginx config locations with the nchan_pubsub directive.
nchan_redis_accurate_subscriber_count #
syntax: nchan_redis_accurate_subscriber_count 1 arg (on/off flag); · context: upstream
An Nginx variable can also be used to set the timeout dynamically. - nchan_redis_accurate_subscriber_count arguments: 1 default: off context: upstream > When disabled, use fast but potentially inaccurate subscriber counts.
nchan_redis_cluster_check_interval_backoff #
syntax: nchan_redis_cluster_check_interval_backoff 1 arg; · context: upstream
Defaults to 'off' for legacy reasons, but will be enabled by default in the future. - nchan_redis_cluster_check_interval_backoff <floating point> >= 0, ratio of current delay arguments: 1 default: 2 (increase delay by 200% each try) context: upstream > Add an exponentially increasing delay to the Redis cluster check interval.
nchan_redis_cluster_check_interval_jitter #
syntax: nchan_redis_cluster_check_interval_jitter 1 arg; · context: upstream
Adds random jitter to the Redis cluster check interval, within a range of plus-or-minus half the interval times this factor, defaulting to 0.2.
nchan_redis_cluster_check_interval_max #
syntax: nchan_redis_cluster_check_interval_max 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_cluster_check_interval_min #
syntax: nchan_redis_cluster_check_interval_min 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_cluster_connect_timeout #
syntax: nchan_redis_cluster_connect_timeout 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_cluster_max_failing_time #
syntax: nchan_redis_cluster_max_failing_time 1 arg (duration in ms); · context: upstream
It will attempt to do this until nchan_redis_cluster_max_failing_time is exceeded.
nchan_redis_cluster_recovery_delay #
syntax: nchan_redis_cluster_recovery_delay 1 arg (duration in ms); · context: upstream
Additionally, recovery attempt delays have configurable jitter, exponential backoff, and maximum values. #### Using Redis securely Redis servers can be connected to via TLS by using the nchan_redis_ssl config setting in an upstream block, or by using the rediss:// schema for the server URLs.
nchan_redis_cluster_recovery_delay_backoff #
syntax: nchan_redis_cluster_recovery_delay_backoff 1 arg; · context: upstream
Additionally, recovery attempt delays have configurable jitter, exponential backoff, and maximum values. #### Using Redis securely Redis servers can be connected to via TLS by using the nchan_redis_ssl config setting in an upstream block, or by using the rediss:// schema for the server URLs.
nchan_redis_cluster_recovery_delay_jitter #
syntax: nchan_redis_cluster_recovery_delay_jitter 1 arg; · context: upstream
Additionally, recovery attempt delays have configurable jitter, exponential backoff, and maximum values. #### Using Redis securely Redis servers can be connected to via TLS by using the nchan_redis_ssl config setting in an upstream block, or by using the rediss:// schema for the server URLs.
nchan_redis_cluster_recovery_delay_max #
syntax: nchan_redis_cluster_recovery_delay_max 1 arg (duration in ms); · context: upstream
Additionally, recovery attempt delays have configurable jitter, exponential backoff, and maximum values. #### Using Redis securely Redis servers can be connected to via TLS by using the nchan_redis_ssl config setting in an upstream block, or by using the rediss:// schema for the server URLs.
nchan_redis_command_timeout #
syntax: nchan_redis_command_timeout 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_connect_timeout #
syntax: nchan_redis_connect_timeout 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_discovered_ip_range_blacklist #
syntax: nchan_redis_discovered_ip_range_blacklist 1 arg; · context: upstream
Blocks Nchan from connecting to autodiscovered Redis cluster nodes whose IPs fall within the specified CIDR ranges.
nchan_redis_fakesub_timer_interval #
syntax: nchan_redis_fakesub_timer_interval 1 arg (duration in ms); · context: http
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_idle_channel_cache_timeout #
syntax: nchan_redis_idle_channel_cache_timeout 1 arg (duration in seconds); · context: http, server, location
Duration in seconds; accepts s / m / h / d suffixes.
nchan_redis_idle_channel_keepalive_backoff #
syntax: nchan_redis_idle_channel_keepalive_backoff 1 arg; · context: upstream
Sets the exponential backoff multiplier applied to the idle-channel keepalive TTL in Redis.
nchan_redis_idle_channel_keepalive_jitter #
syntax: nchan_redis_idle_channel_keepalive_jitter 1 arg; · context: upstream
Sets the jitter multiplier applied to the idle-channel keepalive TTL in Redis.
nchan_redis_idle_channel_keepalive_max #
syntax: nchan_redis_idle_channel_keepalive_max 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_idle_channel_keepalive_min #
syntax: nchan_redis_idle_channel_keepalive_min 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_idle_channel_keepalive_safety_margin #
syntax: nchan_redis_idle_channel_keepalive_safety_margin 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_load_scripts_unconditionally #
syntax: nchan_redis_load_scripts_unconditionally 1 arg (on/off flag); · context: upstream
Boolean directive — set to "on" or "off".
nchan_redis_namespace #
syntax: nchan_redis_namespace 1 arg (string); · context: http, server, location, upstream
All Nchan-related keys in redis will be of the form "nchan_redis_namespace:*" .
nchan_redis_nostore_fastpublish #
syntax: nchan_redis_nostore_fastpublish 1 arg (on/off flag); · context: http, server, upstream
Boolean directive — set to "on" or "off".
nchan_redis_optimize_target #
syntax: nchan_redis_optimize_target 1 arg; · context: upstream
Also from 1.2.0 onward, nchan_redis_optimize_target can be used to prefer optimizing Redis slaves for CPU or bandwidth.
nchan_redis_pass #
syntax: nchan_redis_pass 1 arg; · context: http, server, location
It can also auto-discover and use Redis slaves to balance PUBSUB traffic. <!-- commands: nchan_redis_server nchan_redis_pass --> #### Redis Cluster Nchan also supports using Redis Cluster, which adds scalability via sharding channels among cluster nodes.
nchan_redis_pass_inheritable #
syntax: nchan_redis_pass_inheritable 1 arg (on/off flag); · context: http, server, location
Boolean directive — set to "on" or "off".
nchan_redis_password #
syntax: nchan_redis_password 1 arg (string); · context: upstream
A password and optional username for the AUTH command can be set by the nchan_redis_username and nchan_redis_password config settings in an upstream block, or by using the redis://<username>:<password>@hostname server URL schema.
nchan_redis_ping_interval #
syntax: nchan_redis_ping_interval 1 arg (duration in seconds); · context: http, server, location, upstream
All servers in the upstream block will use this password _unless_ a different password is specified by a server URL. - nchan_redis_ping_interval arguments: 1 default: 4m context: http, server, upstream, location > Send a keepalive command to redis to keep the Nchan redis clients from disconnecting.
nchan_redis_publish_msgpacked_max_size #
syntax: nchan_redis_publish_msgpacked_max_size 1 arg (size (k/m/g)); · context: http
Size in bytes; accepts k / m / g suffixes.
nchan_redis_reconnect_delay #
syntax: nchan_redis_reconnect_delay 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_reconnect_delay_backoff #
syntax: nchan_redis_reconnect_delay_backoff 1 arg; · context: upstream
Adds an exponentially increasing delay to Redis reconnection retries based on the previous delay plus jitter, defaulting to 0.5.
nchan_redis_reconnect_delay_jitter #
syntax: nchan_redis_reconnect_delay_jitter 1 arg; · context: upstream
Adds random jitter to the Redis reconnection delay, within a range of plus-or-minus half the delay times this factor, defaulting to 0.1.
nchan_redis_reconnect_delay_max #
syntax: nchan_redis_reconnect_delay_max 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_retry_commands #
syntax: nchan_redis_retry_commands 1 arg (on/off flag); · context: upstream
Boolean directive — set to "on" or "off".
nchan_redis_retry_commands_max_wait #
syntax: nchan_redis_retry_commands_max_wait 1 arg (duration in ms); · context: upstream
Duration in milliseconds; accepts ms / s / m suffixes.
nchan_redis_server #
syntax: nchan_redis_server 1 arg; · context: upstream
It can also auto-discover and use Redis slaves to balance PUBSUB traffic. <!-- commands: nchan_redis_server nchan_redis_pass --> #### Redis Cluster Nchan also supports using Redis Cluster, which adds scalability via sharding channels among cluster nodes.
nchan_redis_ssl #
syntax: nchan_redis_ssl 1 arg (on/off flag); · context: upstream
Additionally, recovery attempt delays have configurable jitter, exponential backoff, and maximum values. #### Using Redis securely Redis servers can be connected to via TLS by using the nchan_redis_ssl config setting in an upstream block, or by using the rediss:// schema for the server URLs.
nchan_redis_ssl_ciphers #
syntax: nchan_redis_ssl_ciphers 1 arg (string); · context: upstream
Stores a single string value.
nchan_redis_ssl_client_certificate #
syntax: nchan_redis_ssl_client_certificate 1 arg (string); · context: upstream
Stores a single string value.
nchan_redis_ssl_client_certificate_key #
syntax: nchan_redis_ssl_client_certificate_key 1 arg (string); · context: upstream
Stores a single string value.
nchan_redis_ssl_server_name #
syntax: nchan_redis_ssl_server_name 1 arg (string); · context: upstream
Stores a single string value.
nchan_redis_ssl_trusted_certificate #
syntax: nchan_redis_ssl_trusted_certificate 1 arg (string); · context: upstream
Defaults to the system's SSL cert path unless nchan_redis_ssl_trusted_certificate is set - nchan_redis_ssl_verify_certificate [ on | off ] arguments: 1 default: on context: upstream > Should the server certificate be verified when using TLS for Redis connections?
nchan_redis_ssl_trusted_certificate_path #
syntax: nchan_redis_ssl_trusted_certificate_path 1 arg (string); · context: upstream
Stores a single string value.
nchan_redis_ssl_verify_certificate #
syntax: nchan_redis_ssl_verify_certificate 1 arg (on/off flag); · context: upstream
Defaults to the system's SSL cert path unless nchan_redis_ssl_trusted_certificate is set - nchan_redis_ssl_verify_certificate [ on | off ] arguments: 1 default: on context: upstream > Should the server certificate be verified when using TLS for Redis connections?
nchan_redis_storage_mode #
syntax: nchan_redis_storage_mode 1 arg; · context: http, server, location, upstream
Useful to disable when testing with a self-signed server certificate. - nchan_redis_storage_mode [ distributed | backup | nostore ] arguments: 1 default: distributed context: http, server, upstream, location > The mode of operation of the Redis server.
nchan_redis_subscribe_weights #
syntax: nchan_redis_subscribe_weights 1 arg; · context: upstream
The nchan_redis_subscribe_weights setting is available to fine-tune this load-balancing.
nchan_redis_upstream_stats #
syntax: nchan_redis_upstream_stats 1 arg; · context: server, location
The response is JSON of the form: For brevity, the entire command_totals hash is omitted in this documentation. <!-- commands: nchan_redis_upstream_stats nchan_redis_upstream_stats_disconnected_timeout nchan_redis_upstream_stats_enabled --> ## Introspection There are several ways to see what's happening inside Nchan.
nchan_redis_upstream_stats_disconnected_timeout #
syntax: nchan_redis_upstream_stats_disconnected_timeout 1 arg (on/off flag); · context: upstream
The response is JSON of the form: For brevity, the entire command_totals hash is omitted in this documentation. <!-- commands: nchan_redis_upstream_stats nchan_redis_upstream_stats_disconnected_timeout nchan_redis_upstream_stats_enabled --> ## Introspection There are several ways to see what's happening inside Nchan.
nchan_redis_upstream_stats_enabled #
syntax: nchan_redis_upstream_stats_enabled 1 arg (on/off flag); · context: upstream
The response is JSON of the form: For brevity, the entire command_totals hash is omitted in this documentation. <!-- commands: nchan_redis_upstream_stats nchan_redis_upstream_stats_disconnected_timeout nchan_redis_upstream_stats_enabled --> ## Introspection There are several ways to see what's happening inside Nchan.
nchan_redis_url #
syntax: nchan_redis_url 1 arg; · context: http, server, location
Specifies the Redis server address as a redis:// URL or host[:port] shorthand, defaulting to 127.0.0.1:6379.
nchan_redis_username #
syntax: nchan_redis_username 1 arg (string); · context: upstream
A password and optional username for the AUTH command can be set by the nchan_redis_username and nchan_redis_password config settings in an upstream block, or by using the redis://<username>:<password>@hostname server URL schema.
nchan_redis_wait_after_connecting #
syntax: nchan_redis_wait_after_connecting 1 arg; · context: http, server, location
Obsolete directive; ignored with a warning logged and has no configuration effect.
nchan_storage_engine #
syntax: nchan_storage_engine 1 arg; · context: http, server, location
Don't mess with this setting unless you know what you are doing! - nchan_storage_engine [ memory | redis ] arguments: 1 default: memory context: http, server, location > Development directive to completely replace default storage engine.
nchan_store_messages #
syntax: nchan_store_messages 1 arg; · context: http, server, location, location-if
Used for channel statistics, message storage, and interprocess communication. more details - nchan_store_messages [ on | off ] arguments: 1 default: on context: http, server, location, if legacy name: push_store_messages > Publisher configuration. "off" is equivalent to setting nchan_message_buffer_length 0, which disables the buffering of old messages.
nchan_stub_status #
syntax: nchan_stub_status no args; · context: location
This string can use any Nginx and Nchan variables. ### nchan_stub_status Stats Like Nginx's stub_status, nchan_stub_status is used to get performance metrics.
nchan_subscribe_existing_channels_only #
syntax: nchan_subscribe_existing_channels_only 1 arg (on/off flag); · context: http, server, location
Does not include subscribers on other Nchan instances when using a shared Redis server. - nchan_subscribe_existing_channels_only [ on | off ] arguments: 1 default: off context: http, server, location legacy name: push_authorized_channels_only > Whether or not a subscriber may create a channel by sending a request to a subscriber location.
nchan_subscribe_request #
syntax: nchan_subscribe_request 1 arg; · context: server, location, location-if
Without additional configuration, this turns a location into an echo server. more details - nchan_subscribe_request <url> arguments: 1 context: server, location, if > Send GET request to internal location (which may proxy to an upstream server) after subscribing.
nchan_subscriber #
syntax: nchan_subscriber no args; · context: server, location, location-if
This can be used to erase messages or to scale an existing channel's message buffer as desired. ## Subscriber Endpoints Subscriber endpoints are Nginx config locations with the nchan_subscriber directive.
nchan_subscriber_channel_id #
syntax: nchan_subscriber_channel_id 1 arg; · context: server, location, location-if
The queue is traversed automatically, starting at the position defined by the nchan_subscriber_first_message setting. > The value is a list of permitted subscriber types. more details - nchan_subscriber_channel_id arguments: 1 - 7 default: (none) context: server, location, if > Channel id for subscriber location.
nchan_subscriber_compound_etag_message_id #
syntax: nchan_subscriber_compound_etag_message_id 1 arg (on/off flag); · context: server, location, location-if
Boolean directive — set to "on" or "off".
nchan_subscriber_first_message #
syntax: nchan_subscriber_first_message 1 arg; · context: server, location, location-if
Sending a request without a "If-Modified-Since" or "If-None-Match" headers returns the oldest message in a channel's message queue, or waits until the next published message, depending on the value of the nchan_subscriber_first_message config directive.
nchan_subscriber_http_raw_stream_separator #
syntax: nchan_subscriber_http_raw_stream_separator 1 arg; · context: server, location, location-if
Messages are appended to the response body, separated by a newline or configurable by nchan_subscriber_http_raw_stream_separator. <!-- tag:subscriber-rawstream --> - ### HTTP Chunked Transfer This subscription method uses the chunked Transfer-Encoding to receive messages.
nchan_subscriber_info #
syntax: nchan_subscriber_info no args; · context: location
Automatically terminated with a newline character if not explicitly set to an empty string. - nchan_subscriber_info arguments: 0 context: location > A subscriber location for debugging the state of subscribers on a given channel.
nchan_subscriber_info_string #
syntax: nchan_subscriber_info_string 1 arg; · context: server, location
The subscribers of the channel specified by nchan_channel_id evaluate nchan_subscriber_info_string and send it back to the requested on this location.
nchan_subscriber_last_message_id #
syntax: nchan_subscriber_last_message_id 1 arg; · context: server, location, location-if
This behavior can be configured via the nchan_subscriber_last_message_id config.
nchan_subscriber_message_id_custom_etag_header #
syntax: nchan_subscriber_message_id_custom_etag_header 1 arg (string); · context: server, location, location-if
Used primarily as a workaround for the inability to set the first Last-Message-Id of a web browser's EventSource object. - nchan_subscriber_message_id_custom_etag_header arguments: 1 default: (none) context: server, location, if > Use a custom header instead of the Etag header for message ID in subscriber responses.
nchan_subscriber_timeout #
syntax: nchan_subscriber_timeout 1 arg (duration in seconds); · context: http, server, location, location-if
Duration in seconds; accepts s / m / h / d suffixes.
nchan_unsubscribe_request #
syntax: nchan_unsubscribe_request 1 arg; · context: server, location, location-if
These should point to Nginx locations configured to forward requests to an upstream proxy (your application): In order for nchan_unsubscribe_request to work correctly, the location it points to must have proxy_ignore_client_abort on;.
nchan_use_redis #
syntax: nchan_use_redis 1 arg; · context: http, server, location
Nchan can also be scaled out to multiple Nginx instances using the Redis storage engine, and that too can be scaled up beyond a single-point-of-failure by using Redis Cluster. ## Install #### Download Packages - Arch Linux: nginx-mod-nchan and nginx-mainline-mod-nchan are available in the Arch User Repository. - Mac OS X: a homebrew package is available.
nchan_websocket_client_heartbeat #
syntax: nchan_websocket_client_heartbeat 2 args; · context: server, location, location-if
Disabled for longpoll and interval-polling subscribers. more details - nchan_websocket_client_heartbeat <heartbeat_in> <heartbeat_out> arguments: 2 default: none (disabled) context: server, location, if > Most browser Websocket clients do not allow manually sending PINGs to the server.
nchan_websocket_ping_interval #
syntax: nchan_websocket_ping_interval 1 arg (duration in seconds); · context: server, location, location-if
Server-initiated keep-alive pings can be configured with the nchan_websocket_ping_interval config directive.
push_min_message_buffer_length #
syntax: push_min_message_buffer_length 1 arg; · context: server, location, location-if
Obsolete legacy directive; ignored with a warning logged and has no configuration effect.
push_subscriber_concurrency #
syntax: push_subscriber_concurrency 1 arg; · context: server, location, location-if
Obsolete legacy directive; ignored with a warning unless set to 'broadcast', the only still-supported value.
Example
#enable group accounting
nchan_channel_group_accounting on;
location ~ /pubsub/(\w+)$ {
nchan_pubsub;
nchan_channel_group "limited";
nchan_channel_id $1;
}
location ~ /prelimited_pubsub/(\w+)$ {
nchan_pubsub;
nchan_channel_group "limited";
nchan_channel_id $1;
nchan_group_max_subscribers 100;
nchan_group_max_messages_memory 50M;
}
location /group {
nchan_channel_group limited;
nchan_group_location;
nchan_group_max_channels $arg_max_channels;
nchan_group_max_messages $arg_max_messages;
nchan_group_max_messages_memory $arg_max_messages_mem;
nchan_group_max_messages_disk $arg_max_messages_disk;
nchan_group_max_subscribers $arg_max_subs;
}