uwsgi_pass
The `uwsgi_pass` directive forwards requests to a uWSGI application server.
Description
The uwsgi_pass directive is used within NGINX configurations to specify the address of a uWSGI server, enabling communication between NGINX and uWSGI applications. When a request is received that matches the specified location block, NGINX forwards the request data to the designated uWSGI server using either a TCP socket or a Unix domain socket, depending on the specified address format. This allows for seamless integration of web applications written in languages like Python, Ruby, or others that are supported by uWSGI.
The directive can be specified with one argument, which can take the form of an IP address and port (for TCP communication) or a Unix socket path. For example, uwsgi_pass 127.0.0.1:8000; routes requests to a uWSGI server running on localhost at port 8000. Alternatively, you might use uwsgi_pass unix:/path/to/socket; to send requests over a Unix socket, which can improve performance due to lower overhead compared to TCP.
Using uwsgi_pass, you can also configure additional parameters, such as setting timeouts and passing variables to the uWSGI application through NGINX. It is crucial that the uWSGI server is properly configured to handle the incoming requests based on the application's specifications, including routing and request processing logic, as NGINX acts merely as a reverse proxy in this context.
Config Example
location /app {
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}Ensure that the uWSGI server is running and accessible at the defined URL.
If using a Unix socket, ensure that the NGINX process has permission to access the socket file.
Do not forget to include uwsgi_params to properly pass necessary parameters to the uWSGI server.