Skip to content

Instantly share code, notes, and snippets.

@henocdz
Last active September 6, 2016 17:55
Show Gist options
  • Select an option

  • Save henocdz/86a9a3fb0d9bb28d7083 to your computer and use it in GitHub Desktop.

Select an option

Save henocdz/86a9a3fb0d9bb28d7083 to your computer and use it in GitHub Desktop.
upstream backend_staging {
server SOME_IP:PORT weight=5 max_fails=3 fail_timeout=30s;
}
server {
listen 80;
server_name www.domain.com;
return 301 http://$server_name$request_uri;
}
server {
client_max_body_size 5M;
listen 80;
server_name domain.com;
access_log /var/log/nginx/staging-access.log;
error_log /var/log/nginx/staging-error.log;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 300s;
proxy_pass http://backend_staging;
}
location /static/ {
alias /home/static/;
expires 30d;
add_header Cache-Control "public";
}
location /media/ {
alias /var/media/;
expires 30d;
add_header Cache-Control "public";
}
error_page 500 502 503 504 /media/50x.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment