pass
The 'pass' directive defines where to route client requests within the NGINX stream module.
Description
The 'pass' directive is used to forward client requests to a specified upstream server within the NGINX stream module context, which is typically used for TCP and UDP traffic. The directive specifies an upstream server that will handle the incoming connections, allowing for load balancing and failover capabilities. The directive can include options such as defining a server name or specifying a port number.
When a connection matches the criteria defined in the stream block, the 'pass' directive tells NGINX to establish a connection to the specified upstream server and relay the data packets between the client and the upstream server. This effectively makes NGINX act as a proxy for stream traffic, providing features such as SSL termination and maintaining a connection pool. It’s important for administrators to ensure the specified upstream server configuration is correct to avoid connection failures.
The directive can be used in various contexts within the 'stream' block but is mainly defined within a 'server' block, where a single upstream destination is specified. This modular approach allows for flexibility in routing and managing connections effectively.
Config Example
stream {
upstream backend {
server backend1.example.com:1234;
server backend2.example.com:1234;
}
server {
listen 1234;
pass backend;
}
}Ensure upstream server is reachable; otherwise, connections will fail.
Avoid using the 'pass' directive in HTTP contexts; it is specific to stream contexts.
Be aware of connection handling — NGINX keeps connections open for efficient data transfer, which may lead to resource issues if not properly managed.