scgi_pass

The `scgi_pass` directive forwards requests to an SCGI server.

Syntaxscgi_pass URL;
Defaultnone
Contextlocation, if in location
Arguments1

Description

The scgi_pass directive in NGINX is used to pass requests to an SCGI (Simple Common Gateway Interface) backend. It is commonly utilized for routing HTTP requests to web applications that communicate via the SCGI protocol. When a request matches the location block where scgi_pass is defined, NGINX creates an SCGI request and forwards the incoming HTTP data over to the specified SCGI server.

There are several configurations possible with scgi_pass. The argument to this directive is the address of the SCGI server, which can be specified either as an IP address and port (e.g., 127.0.0.1:4000) or as a Unix socket address (e.g., unix:/var/run/scgi.sock). NGINX then constructs an SCGI request according to the specified server's requirements, sending necessary headers and maintaining the connection until a response is received or the request times out.

scgi_pass can be placed within location blocks or even conditional if blocks within those location blocks, providing flexibility on how requests are routed based on the URI or other conditions. It is also common to use it in tandem with other directives for added functionality, such as buffering or request timeouts.

Config Example

location /app {
    scgi_pass 127.0.0.1:4000;
    include scgi_params;
}

Ensure that the SCGI server is running and accessible from NGINX.

Using the wrong protocol (like HTTP instead of SCGI) can lead to errors in communication.

If using Unix sockets, make sure the socket permissions allow the NGINX user to access it.

← Back to all directives