nginx + uwsgi: — unavailable modifier requested: 0

2019-01-30 17:28发布

问题:

Ubuntu 12.04, nginx 1.2.0, uwsgi 1.0.3.

I start uwsgi with the following command:

uwsgi -s 127.0.0.1:9010 -M -t 30 -A 4 -p 4 -d /var/log/uwsgi.log

On each request nginx replies with 502 and uwsgi writes to log the following line:

-- unavailable modifier requested: 0 --

回答1:

Installing the python plugin for uwsgi with apt-get install uwsgi-plugin-python for python 2 or apt-get install uwsgi-plugin-python3 for python 3 and adding plugins = python to the individual uwsgi app config solves this problem.

(Originally answered for Ubuntu 11.10 when using upstart. Python 3 tested on Ubuntu 17.10 with systemd).



回答2:

Solved by installing uwsgi-plugin-python3 plugin and adding --plugin python3 option to uwsgi start command



回答3:

Im starting uwsgi from upstart on Ubuntu. I solved the problem by running apt-get install uwsgi-plugin-python, and then adding plugins=python to my application.ini in /etc/uwsgi/applications-available.



回答4:

from http://uwsgi-docs.readthedocs.org/en/latest/ThingsToKnow.html, "To route requests to a specific plugin, the webserver needs to pass a magic number known as a modifier to the uWSGI instances. By default this number is set to 0, which is mapped to Python."

I'm using 9 for a bash script and it's working. the numbers and their meanings are on this page: http://uwsgi-docs.readthedocs.org/en/latest/Protocol.html

in my nginx configuration:

location ~ .cgi$ {
    include uwsgi_params;
    uwsgi_modifier1 9;
    uwsgi_pass 127.0.0.1:3031;
}