Nginx和uwsgi配置问题

在将uwsgi与uwsgi-file参数一起使用时,我可以在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

但是当我使用

从nginx反向代理时
location ~ \.py$ {
    try_files $uri /index.py =404;
    proxy_pass http://127.0.0.1:9090;
    include uwsgi_params;
}

并禁用uwsgi-file参数:

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

然后我得到这些错误:

浏览器-“内部服务器错误”

nginx控制台-“ GET /hello.py HTTP / 1.1” 500 32

uwsgi控制台-“ GET /hello.py =>在0毫秒(HTTP / 1.0 500)中生成了21个字节,在83个字节中生成了2个报头(核心0上的0个开关)”

请给我一些帮助进行故障排除

shabisb1006810086 回答:Nginx和uwsgi配置问题

解决方案要求uWSGI运行CGI脚本:

  1. 启用CGI插件并按照
  2. 配置uwsgi ini 文件

Running CGI scripts on uWSGI

  1. 使用 uwsgi_modifier1 9 参数配置nginx反向代理
location ~ \.py$ {
        try_files $uri /index.py =404;
        uwsgi_modifier1 9;
        proxy_pass http://127.0.0.1:9090;
        include uwsgi_params;
    }

以及这种类型的“ hello world”测试:

#!/usr/bin/env python
print "Content-type: text/html\n\n"
print "<h1>Hello World</h1>"
本文链接:https://www.f2er.com/3140514.html

大家都在问