Report this

What is the reason for this report?

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

Posted on February 1, 2015

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.

Rgds, Sunil



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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 127.0.0.1:9000 fail_timeout=0;
}

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

    index index.html index.htm;

    client_max_body_size 4G;
    server_name example.com;

    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 fabfile.py 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 settings.py module. Here’s an example:

FABRIC = {
    "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://hg@bitbucket.org/user/project", # 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
    "SECRET_KEY": SECRET_KEY,
    "NEVERCACHE_KEY": NEVERCACHE_KEY,
}

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.