【问题标题】:nginx and uwsgi config issuesnginx 和 uwsgi 配置问题
【发布时间】:2020-03-04 16:31:09
【问题描述】:

当使用带有 uwsgi-file 参数的 uwsgi 时,我可以在 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 从 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 毫秒内生成 21 个字节 (HTTP/1.0 500) 在 83 个字节中生成 2 个标头(0 核心 0 上的开关)”

请帮我解决这个问题

【问题讨论】:

    标签: nginx uwsgi


    【解决方案1】:

    解决方案需要 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>"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-13
      • 2015-11-08
      • 2013-10-02
      • 1970-01-01
      • 1970-01-01
      • 2014-05-29
      • 2012-08-04
      相关资源
      最近更新 更多