Getting Gunicorn to run on port 80

♀尐吖头ヾ 提交于 2019-11-29 12:14:16

问题


I built an API with flask. My app does not have any static assets hence there's no reason for me to use nginx.

I wish to run gunicorn on port 80.

I have a "deploy script":

mkdir .log 2> /dev/null
DEBUG=0 gunicorn -b 0.0.0.0:80 backend:app --access-logfile .log/access.log --error-logfile .log/general.log

I wish to run gunicorn on port 80 with authbind. I followed this guide here.

Note that I am able to run authbind python -m SimpleHTTPServer 80

When I try to run authbind ./deployment.run 80,

I am seeing the following error:

2013-04-25 15:32:55 [24006] [ERROR] Can't connect to ('0.0.0.0', 80)
2013-04-25 15:33:08 [24018] [INFO] Starting gunicorn 0.17.4
2013-04-25 15:33:08 [24018] [ERROR] Retrying in 1 second.
2013-04-25 15:33:09 [24018] [ERROR] Retrying in 1 second.
2013-04-25 15:33:10 [24018] [ERROR] Retrying in 1 second.
2013-04-25 15:33:11 [24018] [ERROR] Retrying in 1 second.
2013-04-25 15:33:12 [24018] [ERROR] Retrying in 1 second.

Any ideas why I am unable to bind gunicorn to port 80?

Any recommendations?


回答1:


Try putting authbind inside your deployment script, e.g.:

mkdir .log 2> /dev/null
DEBUG=0 authbind gunicorn -b 0.0.0.0:80 backend:app --access-logfile .log/access.log --error-logfile .log/general.log

Then just run ./deployment.run 80.

(Also, your script doesn't seem to be using any parameters; perhaps replace 80 in your script with $1?)




回答2:


If you are on a unix-like environment, ports < 1024 (like 80) will require superuser privileges.



来源:https://stackoverflow.com/questions/16225872/getting-gunicorn-to-run-on-port-80

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!