flask+nginx+gunicorn+supervisor用docker方式部署,用supervisor启动后,访问http://127.0.0.1 只能看到nginx的欢迎界面,无法看到flask的界面
相关代码如下:
app.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=80)
flask.conf
server {
listen 80;
server_name 120.0.0.1;
location / {
proxy_pass http://127.0.0.1:8001;
}
}
supervisor.conf
[program:nginx-app]
command = /usr/sbin/nginx -g "daemon off;"
stdout_logfile = /var/log/supervisor/nginx_stdout.log
stdout_logfile_maxbytes = 10MB
stderr_logfile = /var/log/supervisor/nginx_error.log
stderr_logfile_maxbytes = 10MB
[program:app-gunicorn]
command = /usr/local/bin/gunicorn -w 4 -b 127.0.0.1:8001 app:app
directory = /app
stdout_logfile = /var/log/supervisor/gunicorn_out.log
stdout_logfile_maxbytes = 10MB
stderr_logfile = /var/log/supervisor/gunicorn_error.log
stderr_logfile_maxbytes = 10MB
gunicorn日志:
[2018-12-12 03:29:48 +0000] [8824] [INFO] Starting gunicorn 19.9.0
[2018-12-12 03:29:48 +0000] [8824] [INFO] Listening at: http://127.0.0.1:8001 (8824)
[2018-12-12 03:29:48 +0000] [8824] [INFO] Using worker: sync
[2018-12-12 03:29:48 +0000] [8829] [INFO] Booting worker with pid: 8829
[2018-12-12 03:29:49 +0000] [8830] [INFO] Booting worker with pid: 8830
[2018-12-12 03:29:49 +0000] [8831] [INFO] Booting worker with pid: 8831
[2018-12-12 03:29:49 +0000] [8834] [INFO] Booting worker with pid: 8834
启动supervisor后,只能看到nginx欢迎界面,求解~
3 回答
Qyouu
TA贡献1786条经验 获得超11个赞
nginx 配置中 server block 里配的不对;这样写 server_name _;
或者 listen 80 default_server;
添加回答
举报
0/150
提交
取消