0

I am trying to set up uwsgi, which would serve python files in cgi manner. Using Nginx as the proxy for this.

This is my .ini file to run the uwsgi "pyApp.py"

[uwsgi]
plugins = cgi
socket = 127.0.0.1:9010
cgi = /=/usr/share/test/
cgi-allowed-ext = .py
cgi-helper = .py=python

i have a file "firstapp.py" at location /usr/share/test/firstapp.py Its contents are

#!/usr/bin/python
print "Content-type: text/html\n\n"
print "<html><body><h1>It works! Cool!!</h1></body></html>"

I am running the instance of uwsgi with the command

uwsgi --http :9011 --http-modifier1 9 --ini pyApp.ini --master

I have configured several vhosts using nginx. and one of them must point to directory /usr/share/test/ when there is url having "/cgi-bin/" in it.

The nginx config is - [also the only default one among the others]

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/pythonsite.com/html;
        index index.html index.htm;

        server_name pythonsite.com www.pythonsite.com;

        location / {
                try_files $uri $uri/ =404;
        }

        location /cgi-bin {
                include uwsgi_params;
                uwsgi_modifier1 9;
                uwsgi_pass 127.0.0.1:9010;
        }
}

But when i try to access the "cgi" script from the browser via the url

http://pythonsite.com/cgi-bin/firstapp.py

The default URL "pythonsite.com" seems to be working fine but the above URl with "cgi-bin" in it seems to be missing something. I get "502 Bad Gateway". What am i missing. In order to use the python scripts this way?

EDIT:

Also, every time i request the URL http://pythonsite.com/cgi-bin/firstapp.py" in the browser, there is a log on the uwsgi server instance saying

-- unavailable modifier requested: 9 --
5
  • Recheck other things then nginx, i.e. test yourself if your_ip::9011 and your_ip:9010 works. Right now they don't and so you can't blame nginx for bad news. Commented Mar 17, 2015 at 19:33
  • yes, they dont seem to be working, but on the uwsgi logs i get "invalid request block size: 21573 (max 4096)...skip" for 127.0..0.1:9010 and connection was reset on the browser page Commented Mar 17, 2015 at 19:36
  • @DmitryVerkhoturov and for "127.0.0.1:9011" i get "internal Server Error" message on the browser. and uwsgi logs as "--- no python application found, check your startup logs for errors ---" Commented Mar 17, 2015 at 19:42
  • Recheck, google, recheck. I never tried to setup uwsgi, there are easier way like gunicorn for such things. It's strange, why you run uwsgi with --http :9011 parameter? Commented Mar 17, 2015 at 19:44
  • @DmitryVerkhoturov Well, even after removing the --http, its the same.. i am missing something on the way the uwsgi is configured. May be the way .ini file is written, or the way the command for initialising the uwsgi instance is written. Yet to figure out what. Any help is appreciated. Commented Mar 17, 2015 at 20:00

1 Answer 1

0

Well, After much searching and help from my friend HD <-- Awesome person. Here is the answer -

I needed to install cgi with curl http://uwsgi.it/install | bash -s cgi /tmp/uwsgi and then use the new binary in /tmp/uwsgi to run the command to start uwsgi.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.