2015-02-11 75 views
1

我對python,nginx和燒瓶都很陌生,所以把我所描述的東西理解成一粒鹽。nginx如何與運行Flask應用的uWSGI配合使用?

我正在看它前面的燒瓶應用程序和nginx的設置。我理解它的方式,nginx服務器,面向web,後面是一個在uWSGI服務器上運行的應用程序。

我看到上游,服務器和爲nginx配置的位置。所以我知道哪個路由映射到哪個內部端口。

我試圖找到爲燒瓶app/uWSGI服務器配置端口的位置。在日誌中我看到: uWSGI HTTP綁定上:8080 FD 4 但用netstat檢查時,我沒有看到8080端口綁定

在哪個端口上做的Nginx和uWSGI服務器/瓶的應用程序通過請求?該端口在哪裏配置?

謝謝!

+1

https://github.com/mking/flask-uwsgi – vittore 2015-02-11 19:17:50

+0

它取決於你的配置通常它們會通過套接字綁定,而不是端口。 – 2015-02-11 19:22:45

回答

2

您可以使用--socket選項(或相關配置文件值)配置要使用的端口或本地套接字。

[uwsgi] 
master = true 
processes = 8 
threads = 2 
socket = /home/sopython/uwsgi.sock 
vacuum = true 
chdir = /home/sopython 
virtualenv = /home/sopython 
module = sopy:create_app() 

然後您配置nginx與您選擇的端口或套接字進行通信。

server { 
    listen 80 default_server; 
    listen [::]:80 ipv6only=on default_server; 
    server_name sopython.com; 
    root /home/sopython; 

    location /static { 
     alias /home/sopython/lib/python3.4/site-packages/sopy/static; 
    } 

    location/{ 
     include uwsgi_params; 
     uwsgi_param HTTP_HOST $server_name; 
     uwsgi_pass unix:///home/sopython/uwsgi.sock; 
    } 
} 

這是從Python chat room的網站配置中獲取。