fastcgi_bind

The `fastcgi_bind` directive configures the address to which the FastCGI server will bind for accepting requests.

Syntaxfastcgi_bind address [port];
Defaultnone
Contexthttp, server, location
Arguments1-2

Description

The fastcgi_bind directive is used within the NGINX HTTP server to specify the address or socket to which the FastCGI server should bind when processing requests. This directive can take one or two arguments. The first argument is the address (IPv4 or IPv6) or a Unix socket path, which indicates where the FastCGI server can listen for connections. The optional second argument can specify the port to bind to, allowing for more granular control over network interfaces and ports utilized by the FastCGI process.

When using a Unix socket, the syntax would simply be the path to the socket without any port specified. This binding mechanism is crucial for scenarios where multiple FastCGI servers might be running, as it allows NGINX to direct traffic to the correct FastCGI instance. The FastCGI servers can then be efficiently distributed, depending on the binding provided, which can enhance performance by limiting unnecessary network overhead.

Proper configuration of the fastcgi_bind directive is essential when deploying applications on NGINX that rely on FastCGI, ensuring that server resources are correctly allocated based on the demands of the application and maintaining responsiveness to client requests. For context, this directive can be used in the http, server, or location blocks which allows extensive flexibility in configuring FastCGI handlers for different parts of an NGINX installation.

Config Example

location ~ \.php$ {
    fastcgi_pass   127.0.0.1;  # Example FastCGI server address
    fastcgi_bind   127.0.0.1:9000;
}

Ensure the specified address is correct and reachable by the NGINX worker processes.

Avoid binding to addresses not allocated to the server, as this can result in 'address already in use' errors.

When using Unix sockets, ensure the socket path has appropriate permissions for NGINX to access.

← Back to all directives