Nginx Uwsgi

uwsgi is a WSGI server that is commonly used for Python projects. See here for details on installation, configuration, and usage of that server itself.


Example

The minimal configuration of nginx(8) for uwsgi looks like:

location / {
    include /etc/nginx/uwsgi_params;
    uwsgi_pass 127.0.0.1:9000;
}

Many tutorials recommend adding uwsgi_modifier1 30, which will automatically rewrite PATH_INFO and SCRIPT_NAME. This is deprecated and unstable for Python 3.

Uwsgi_params

The uwsgi_params file mirrors the fastcgi_params file from FastCGI.

Here is a generic template, which would work for the above example.

uwsgi_param QUERY_STRING    $query_string;
uwsgi_param REQUEST_METHOD  $request_method;
uwsgi_param CONTENT_TYPE    $content_type;
uwsgi_param CONTENT_LENGTH  $content_length;
uwsgi_param REQUEST_URI     $request_uri;
uwsgi_param PATH_INFO       $document_uri;
uwsgi_param DOCUMENT_ROOT   $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REMOTE_ADDR     $remote_addr;
uwsgi_param REMOTE_PORT     $remote_port;
uwsgi_param SERVER_ADDR     $server_addr;
uwsgi_param SERVER_PORT     $server_port;
uwsgi_param SERVER_NAME     $server_name;


CategoryRicottone

Nginx/Uwsgi (last edited 2023-04-22 20:30:12 by DominicRicottone)