DevOps & Deployment March 17, 2025 1 min read

Nginx Configuration for Django Applications

Complete Nginx configuration guide for serving Django with Gunicorn.

H
Hassan Ali
Site reliability engineer
11 views

Table of Contents

  • Loading table of contents...

Nginx + Django Configuration

Nginx as a reverse proxy provides security and performance benefits.

Server Block Configuration

server {
    listen 80;
    server_name yourdomain.com;
    
    location /static/ {
        alias /var/www/myproject/static/;
    }
    
    location /media/ {
        alias /var/www/myproject/media/;
    }
    
    location / {
        proxy_pass http://unix:/run/gunicorn.sock;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Related Articles

Discussion 0

No comments yet. Be the first to start the discussion!

Leave a Comment