我的Flask应用程序通过uWSGI运行,我正在使用TCP套接字与NGINX交谈。 configuration是非常基本的:
application.conf
server { listen 80 default_server; location / { uwsgi_pass 127.0.0.1:9000; include uwsgi_params; } }
我在.ini中指定了TCP套接字:
uwsgi.ini
[uwsgi] socket = 127.0.0.1:9000 # remove the socket once disconnected vacuum = true module = wsgi callable = app processes = 4 threads = 2 master = 1
和我的模块:
wsgi.py
from app import create_app app = create_app('config/development.py') if __name__ == '__main__': app.run()
127.0.0.1:80/只返回404错误(当uWSGI没有运行时,NGINX 502错误)。
我怎样才能让uWSGI和NGINX相互交谈? uWSGI如何通过NGINX服务Flask应用程序?
我通过更改我的Flaskconfiguration来指定服务器来解决问题:
configuration/ development.py
... SERVER_NAME = 'applicationlocal'
然后在NGINXconfiguration中指定该服务器:
application.conf
location / { listen 80; server_name applicationlocal; }
我以前编辑OS X主机文件,以匹配127.0.0.1“applicationlocal”; 现在我可以在“applicationlocal:80 /”而不是“127.0.0.1:80/”访问应用程序。