我正在尝试遵循以下指导来部署Flask服务器:https://medium.com/ymedialabs-innovation/deploy-flask-app-with-nginx-using-gunicorn-and-supervisor-d7a93aa07c18
我按照所有步骤进行了操作,除了主管部分,我完全跳过了该部分,因为该命令不起作用,但是让事情起作用并不重要。
当我跑步时:sudo nginx -t
我得到:nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
什么是问题?我看到其他人遇到此错误,但是解决方案似乎对我不起作用?
这是我的nginx conf文件:
server {
listen 80;
server_name <name>;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
#
# A virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
还有python flask服务器:
from flask import Flask
from flask import render_template
from flask import send_file
app = Flask(__name__, static_url_path="/static", static_folder="/static")
app.static_folder = 'static'
@app.route("/")
def index():
return render_template("index.html")
@app.route("/uploads/resume")
def download_resume():
return send_file("static/documents/resume.pdf")
if __name__ == '__main__':
app.run(port=5010, debug=False, host='0.0.0.0')
答案 0 :(得分:0)
我刚刚注释了以下一行
listen [::]:80 default_server ipv6only=on;