Deploying Nginx + Gunicorn + Flask
Why use both Nginx and Gunicorn?: http://serverfault.com/a/220047Simple explanation: http://prakhar.me/articles/flask-on-nginx-and-gunicorn/
Nginx SSL configuration: https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-with-ssl-as-a-reverse-proxy-for-jenkins
The thing I spent the longest on was getting supervisor to work. Gunicorn kept giving me "gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>", because I was missing the "directory" parameter. I needed to tell supervisor which directory to start from.
[program:my_app]
command=/<path>/venv/prod/bin/gunicorn -w 8 main:app -b 127.0.0.1:8080
user=me
autostart=true
directory=/home/me/my_dir/
stdout_logfile=/home/me/my_dir/gunicorn_supervisor.log
stdout_logfile_maxbytes=20MB
redirect_stderr=true
You will need to create an upstart script to get supervisor to run when the system starts: http://serverfault.com/a/96500