Topic 16 / 40

Production Deployment: Gunicorn, Nginx & SSL

~14 min read  //  Django Series  //  Coding India

1. Deep Architecture

In production, standard python servers are not run directly. We use Gunicorn to run WSGI/ASGI apps across worker threads. Nginx acts as a reverse proxy, handling SSL handshakes and serving static files directly from disk to keep python processes free.

2. The Feynman Gatekeeper

[KNOWLEDGE CHECK] Why should Gunicorn be run behind a reverse proxy like Nginx rather than exposing it directly to public traffic?

3. The Code

# /etc/nginx/sites-available/sanjaya
server {
    listen 80;
    server_name sanjaya.in;

    location /static/ {
        alias /var/www/sanjaya/static/;
    }

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
    }
}

4. The Funnel

Stat Level-Up: Systems Deployer (Lvl 1).
Sanjaya Integration: Route customer dashboard traffic safely over HTTPS endpoints.