nginx 和 uwsgi 配置问题
nginx and uwsgi config issues
当使用带有 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 反向代理时
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
然后我得到这些错误:
浏览器 - "Internal Server Error"
nginx 控制台 - "GET /hello.py HTTP/1.1" 500 32
uwsgi 控制台 - "GET /hello.py => generated 21 bytes in 0 msecs (HTTP/1.0 500) 2 headers in 83 bytes (0 switches on core 0)"
请帮我解决这个问题
解决方案需要 uWSGI 运行 CGI 脚本:
- 启用 CGI 插件并根据
配置 uwsgi ini 文件
- 使用uwsgi_modifier19参数配置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>"
当使用带有 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 反向代理时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
然后我得到这些错误:
浏览器 - "Internal Server Error"
nginx 控制台 - "GET /hello.py HTTP/1.1" 500 32
uwsgi 控制台 - "GET /hello.py => generated 21 bytes in 0 msecs (HTTP/1.0 500) 2 headers in 83 bytes (0 switches on core 0)"
请帮我解决这个问题
解决方案需要 uWSGI 运行 CGI 脚本:
- 启用 CGI 插件并根据 配置 uwsgi ini 文件
- 使用uwsgi_modifier19参数配置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>"