1
votes

when using uwsgi with the uwsgi-file parameter, I can see the correctly rendered page at 127.0.0.1/hello.py:

plugin = python3
master = true
processes = 5
chdir = /var/www/web1/
http = 127.0.0.1:9090
wsgi-file = /var/www/web1/hello.py
stats = 127.0.0.1:9191
chmod-socket = 777
vacuum = true
enable-threads  = true
die-on-term = true

but when i reverse proxy from nginx using

location ~ \.py$ {
    try_files $uri /index.py =404;
    proxy_pass http://127.0.0.1:9090;
    include uwsgi_params;
}

and disable the uwsgi-file parameter:

plugin = python3
master = true
processes = 5
chdir = /var/www/web1/
http = 127.0.0.1:9090
#wsgi-file = /var/www/web1/hello.py
stats = 127.0.0.1:9191
chmod-socket = 777
vacuum = true
enable-threads  = true
die-on-term = true

then I get these errors:

browser - "Internal Server Error"

nginx console - "GET /hello.py HTTP/1.1" 500 32

uwsgi console - "GET /hello.py => generated 21 bytes in 0 msecs (HTTP/1.0 500) 2 headers in 83 bytes (0 switches on core 0)"

can I have some help troubleshooting this please

1

1 Answers

0
votes

Solution requires uWSGI run CGI scripts:

  1. enable the CGI plugin and configure uwsgi ini file as per

Running CGI scripts on uWSGI

  1. configure nginx reverse proxy with the uwsgi_modifier1 9 parameter
location ~ \.py$ {
        try_files $uri /index.py =404;
        uwsgi_modifier1 9;
        proxy_pass http://127.0.0.1:9090;
        include uwsgi_params;
    }

and this type of 'hello world' test:

#!/usr/bin/env python
print "Content-type: text/html\n\n"
print "<h1>Hello World</h1>"