Mezzanine CMS: How to setup gunicorn, nginx and wsgi for production.

February 1, 2015 3.2k views

Hello everyone,

I have deployed Mezzanine CMS on digital ocean Debian droplet. And its running at http://{droplet-ip}:8000. But trying to deploy for production means Mezzanine CMS should run at http://{droplet-ip} and background process should be taken care by nginx, gunicorn.

Followed the Digital ocean documentation for setting-up production site with nginx but no luck! I have no idea where i'm making mistake. Would be greatful if someone can help me with steps - how to configure nginx and other require dependencies for production.

Thank you so much.


1 Answer

Without knowing exactly what you tried, it's hard to give you a very detailed answer, but hopefully this points you in the right direction.

A Nginx reverse proxy configuration would normally look something like this:

upstream app_server {
    server fail_timeout=0;

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    index index.html index.htm;

    client_max_body_size 4G;

    keepalive_timeout 5;

    location /static {
        root /path/to/staric/files;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

Though if you are using Mezzanine, you might want to consider using Fabric to handle your deployment needs. Each Mezzanine project should come with a that will automate setting up a stanadrd Nginx/Gunicorn/Postgres stack. Check out the Mezzanine docs.

Youll need to add some server specific configurable variables in the project’s module. Here’s an example:

    "SSH_USER": "", # SSH username for host deploying to
    "HOSTS": ALLOWED_HOSTS[:1], # List of hosts to deploy to (eg, first host)
    "DOMAINS": ALLOWED_HOSTS, # Domains for public site
    "REPO_URL": "ssh://", # Project's repo URL
    "VIRTUALENV_HOME":  "", # Absolute remote path for virtualenvs
    "PROJECT_NAME": "", # Unique identifier for project
    "REQUIREMENTS_PATH": "requirements.txt", # Project's pip requirements
    "GUNICORN_PORT": 8000, # Port gunicorn will listen on
    "LOCALE": "en_US.UTF-8", # Should end with ".UTF-8"
    "DB_PASS": "", # Live database password
    "ADMIN_PASS": "", # Live admin user password
Have another answer? Share your knowledge.