Getting Gunicorn to run on port 80

2019-02-12 19:10发布

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?

2条回答
神经病院院长
2楼-- · 2019-02-12 19:25

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

查看更多
仙女界的扛把子
3楼-- · 2019-02-12 19:36

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?)

查看更多
登录 后发表回答