尝试用gunicorn+nginx组合在AWS部署一个flask应用,不知道为啥老是不成功。。求助
nginx配置
server {
listen 80 ;
server_name noorders.com ;
root /home/The-Garden-of-Forking-Paths/ ;
access_log /home/The-Garden-of-Forking-Paths/log/nginx.log ;
error_log /home/The-Garden-of-Forking-Paths/log/nginx.err ;
location / {
proxy_pass http://127.0.0.1:5000 ;
proxy_redirect off ;
proxy_set_header Host $host ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
}
location /static/ {
alias /home/The-Garden-of-Forking-Paths/app/static/;
}
}
运行命令sudo service nginx start
gunicorn的配置文件为
workers = 4
bind = '127.0.0.1:5000'
proc_name = 'manage'
pidfile = '/tmp/app.pid'
运行命令 gunicorn --config project.conf manage:app
域名服务商是Godaddy
DNS解析换成了DNSPod
AWS的弹性IP已经加入域名的A记录
折腾挺久了,还是没搞明白,求教是哪一步出了问题?万分感谢!
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
在/etc/nginx/sites-available/default里server上面加入这段试试:
我也是前两天刚弄的新手,不确定这样行不行,试一下?
gunicorn 的
bind = '127.0.0.1:5000'改成bind = '0.0.0.0:5000'试试。感觉
proxy_redirect off不大对