Skip to main content

Flask + Gunicorn + Supervisor + Nginx

This morning, I deployed a Flask application in a Ubuntu 13.04 server with Nginx and Gunicorn. Here is the configuration:

0. My app code base (blog):


1. I created a shell script to run gunicorn:



# user/group to run as
cd /projects/blog
/projects/.venv/blog/bin/gunicorn blog:app -w $NUM_WORKERS -b $ADDRESS

2. Supervisor configuration:


directory = /projects/blog/flaskr/
user = dangtrinhnt
command = /projects/blog/
stdout_logfile = /projects/logs/supervisor_blog.log
stderr_logfile = /projects/logs/supervisor_blog_error.log

3. Nginx configuration:


upstream blog {
    server localhost:5000 fail_timeout=0;
server {
    listen 80;
    access_log /projects/logs/access_blog.log;
    error_log /projects/logs/error_blog.log;
    location /static/ {
        alias /projects/blog/static/;
    location / {
        proxy_pass http://blog;

I used the Flaskr example from Flask project which you can find at

I deployed the blog in a free VM provided by Koding at
(you can get a free one too).

The blog is now live at (only when I'm actively logging in Koding)

It's pretty cool!!!