nchan_redis_url

The nchan_redis_url directive configures the Redis server URL for Nchan's pub/sub message storage.

Syntaxnchan_redis_url URL;
Defaultnone
Contexthttp, server, location
Arguments1

Description

The nchan_redis_url directive specifies the Redis server URL that Nchan will use for storing and handling messages. When messages are published to a channel, they can be buffered and persisted through Redis for reliable delivery to subscribers, even in a distributed environment where multiple Nginx instances could be sharing the same Redis backend. The directive accepts an argument that is the connection string to the Redis server, which generally includes the server address and an optional port number. This configuration allows Nchan to leverage Redis’s powerful data structures and persistence features, ensuring that messages are not lost and can be retrieved by subscribers, regardless of their connection state.

The flexibility of this directive also allows for a scalable architecture where multiple Nginx servers can share the same Redis instance. This means that messages produced on one server can be consumed by subscribers connected to another server seamlessly, enabling horizontal scaling of message delivery infrastructure. Such configurations are invaluable in high-load scenarios where message throughput and reliability are critical. To set up Nchan with Redis, you simply need to ensure that the Redis server is running and accessible from your Nginx instance, then specify the server URL using this directive in the appropriate context (http, server, or location).

Config Example

http {
    nchan_redis_url "redis://127.0.0.1:6379";
}

Ensure that the Redis server is running and accessible from Nginx; otherwise, message storage will fail.

Using incorrect Redis connection strings (e.g., incorrect ports or IP addresses) can lead to errors in message delivery.

Make sure required permissions are set in Redis to allow Nchan to perform the necessary operations.

← Back to all directives