Skip to content

Instantly share code, notes, and snippets.

@chrisvoncsefalvay
Forked from lciolecki/nginx.conf
Created November 6, 2017 11:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisvoncsefalvay/0c0303ca78b8478f285c42761a0efaeb to your computer and use it in GitHub Desktop.
Save chrisvoncsefalvay/0c0303ca78b8478f285c42761a0efaeb 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