Gunicorn bind both HTTP and HTTPS port

Viewed 219

I want to host a python application on Gunicorn server in two different ports. One at HTTP port (8000) and another at HTTPS port(8001). How can we achieve this in Gunicorn?

For http and https, I believe I need to pass two separate gunicorn_config.py files, one which has server certificates and another without any certificate (http).

Is it possible to do so? Or do I have to run two different instance of gunicorn server separatly?

I am using this to run the server:

gunicorn --config gunicorn_config.py application.main:app
1 Answers

According to https://github.com/benoitc/gunicorn/issues/1466 you can do it like this:

gunicorn -k uvicorn.workers.UvicornWorker -w 3 -b 0.0.0.0:30000 -t 360 --reload app:app & gunicorn -k uvicorn.workers.UvicornWorker -w 3 --certfile certfile.txt --keyfile keyfile.txt --ca-certs ca_certs.txt -b 0.0.0.0:8443 -t 360 --reload app:app 
Related