nginx.conf 1.24 KB
server {
    listen 80;
    charset utf-8;
    server_name URL-PROJECT-NAME;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    charset utf-8;
    server_name URL-PROJECT-NAME;
    client_max_body_size 4G;
    
    ssl on;
    ssl_certificate /etc/letsencrypt/live/URL-PROJECT-NAME/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/URL-PROJECT-NAME/privkey.pem;
    
    
    location /static/ {
        # autoindex off;
        alias /PATH/PROJECT/PROJECT-NAME/static/;
    }
    
    location /media/ {
        # autoindex off;
        alias /PATH/PROJECT/PROJECT-NAME/media/;
    }
    
    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 600;
        proxy_send_timeout 600;
        proxy_read_timeout 600;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
    
    ## Logs
    access_log /PATH/PROJECT/deployment/logs/nginx-access.log;
    error_log /PATH/PROJECT/deployment/logs/nginx-errors.log;
    
}