OpenStack Horizon with NGINX + uWSGI

To my knowledge the most frequent way of deploying OpenStack’s Horizon django application is via apache, and modwsgi. I think this is primarily because in the early days of devstack the community decided that apache was (at the time) the most common web server.

But now it’s 2013, and things have changed. NGINX is the new hottness, and gunicorn has been replaced with uWSGI for speed and reliability.

Since I didn’t have any specific Horizon instructions, I would like to share some of the configuration I used recently to deploy Horizon using NGINX and uWSGI.

The operating system I used was Ubuntu 13.04 (raring), with the addition of Ubuntu’s cloud archive apt repositories.

Install Dependencies

# Remove the backslash, my websites markdown parser is broken
sudo echo "deb http:\// precise-updates/grizzly main" | tee -a /etc/apt/sources.list.d/ubuntu-cloud-archive-grizzly

sudo apt-get update
sudo apt-get install -y build-essential python-dev python-pip nginx-extras memcached node-less openstack-dashboard

sudo update-rc.d -f  apache2 remove # Disable apache

sudo pip install uwsgi


server {
    listen 80;

    location / { try_files $uri @horizon; }
    location @horizon {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/horizon.sock;
    location /static {
      alias /usr/share/openstack-dashboard/static/;


master = true
processes = 10
threads = 2
chmod-socket = 666

socket = /tmp/horizon.sock
pidfile = /tmp/
log-syslog = '[horizon]'

chdir = /usr/share/openstack-dashboard/
env = DJANGO_SETTINGS_MODULE=openstack_dashboard.settings
module = django.core.handlers.wsgi:WSGIHandler()


description "OpenStack Horizon App"

start on runlevel [2345]
stop on runlevel [!2345]


exec uwsgi --ini /etc/uwsgi/horizon.ini

Then you can control horizon via upstart:

sudo service horizon start
sudo service horizon stop
sudo service horizon restart