Skip to content

Instantly share code, notes, and snippets.

@lciolecki
Created January 5, 2017 08:52
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save lciolecki/a82c4e5f250bfa5c7d63d1b7f65d5a0c to your computer and use it in GitHub Desktop.
Save lciolecki/a82c4e5f250bfa5c7d63d1b7f65d5a0c to your computer and use it in GitHub Desktop.
Nginx config for django rest framework + angular application
server {
listen 80;
listen 443 ssl;
server_name your-domain.com;
charset utf-8;
client_max_body_size 32M;
root /project/static;
index index.html;
error_page 404 /404.html;
error_page 502 /service-unavailable.html;
error_page 503 /service-unavailable.html;
location ~^/((?!static|media).)*\.(gif|jpg|jpeg|png|js|css|woff|woff2|eot|svg|ttf)$ {
gzip_static on;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
}
location /media {
alias /project-RW/media;
gzip_static on;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
access_log off;
}
location /static {
alias /project/static;
gzip_static on;
expires 1y;
add_header Cache-Control public;
add_header ETag "";
access_log off;
}
location ~^/(django-admin|api|ckeditor) {
include uwsgi_params;
uwsgi_pass django-project;
uwsgi_read_timeout 300;
proxy_set_header X-Forwarded-Protocol $scheme;
}
location / {
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri $uri/ /index.html =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment