redis2_pass
The `redis2_pass` directive defines the address of the Redis server to which NGINX will forward requests for Redis operations.
Description
The redis2_pass directive is part of the NGINX upstream module for the Redis 2.0 protocol, allowing users to specify a Redis server address that NGINX will connect to for processing requests related to Redis operations. This directive can be used within a location block or within an if block inside a location, making it versatile for various routing needs in your NGINX configuration. By specifying the address of the Redis server, the directive enables NGINX to act as a proxy that translates HTTP requests to Redis commands, facilitating interactions with a Redis database.
Each redis2_pass directive can take a single argument, which is the address of the Redis server formatted as either an IP address or domain name with an associated port, e.g., 127.0.0.1:6379. When a request reaches a location that includes redis2_pass, after processing any specified Redis queries (using directives such as redis2_query), NGINX will forward these queries to the defined Redis server. It also supports connection pooling and other upstream configurations, allowing for enhanced performance and reliability when handling multiple Redis operations.
Config Example
location /myredis {
redis2_query get mykey;
redis2_pass 192.168.1.100:6379;
}Ensure that the address provided is reachable and the Redis server is running to avoid connection errors.
If using multiple redis2_pass directives within a location, each should point to valid addresses; otherwise unintended behavior may occur.
Be cautious with if conditions in locations since improper usage may lead to unexpected processing results.