NGINX, uWSGI with CGI plugin, Python scripts - 502 Bad Gateway NGINX, uWSGI with CGI plugin, Python scripts - 502 Bad Gateway nginx nginx

NGINX, uWSGI with CGI plugin, Python scripts - 502 Bad Gateway


You're getting 500's because the uWSGI CGI plugin doesn't use WSGI, it uses CGI (took me a few hours to figure that difference out). The python script you're using implements the WSG Interface (with an "application" method) but isn't actually CGI-compatible.

To make it compatible just output the HTTP response headers, a new line, and then the HTTP body to standard out (https://en.wikipedia.org/wiki/Common_Gateway_Interface#Example).

So for your example this would become:

print("Content-Type: text/html")print("Status: 200 OK")print()print("Ololo")