我用 nginx + gunicorn 布署flask應(yīng)用。發(fā)現(xiàn)nginx 與 gunicorn 和 flask 分別都能正常運行,但配合起來沒有正常工作。主要是nginx的監(jiān)聽外網(wǎng)80端口正常,卻無法反向代理給5000端口的gunicorngunicorn的命令如下gunicorn wsgi --bind 0.0.0.0:5000我通過查看端口發(fā)現(xiàn)gunicorn + flask成功運行在了5000端口也在瀏覽器中通過5000端口可以成功訪問服務(wù)器中的網(wǎng)站nginx 的設(shè)置如下/etc/nginx/sites-enabled/webweb文件中的內(nèi)容如下server { listen 80; location / { proxy_pass http://localhost:5000;
}
}我用通過service nginx restart多次成功重啟了nginx。 用nginx -t查看配置是否成功,結(jié)果如下:nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful我用瀏覽器通過ip不加端口(默認80端口)訪問,網(wǎng)頁內(nèi)容是welcome to nginx
nginx + gunicorn 沒有成功 反向代理
牛魔王的故事
2018-09-23 20:10:15