Skip to content

Instantly share code, notes, and snippets.

@gamorales
Last active May 21, 2020 14:52
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 gamorales/19a9032daf0def6bcd40780fdf0daa3d to your computer and use it in GitHub Desktop.
Save gamorales/19a9032daf0def6bcd40780fdf0daa3d to your computer and use it in GitHub Desktop.
# Add these to /etc/hosts
# 127.0.0.1 localhost
# 127.0.0.1 local.host
server {
server_name localhost local.host;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
index index.html;
# Disable favicon.ico logging
location = /favicon.ico {
log_not_found off;
access_log off;
}
location /static/ {
alias /path/to/staticfiles/;
expires 30d;
}
location / {
error_page 404 /<url_to_redirect>/;
proxy_set_header x-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8000;
proxy_pass_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_connect_timeout 10;
proxy_read_timeout 10;
}
# Disable static content logging and set cache time to max
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
access_log off;
log_not_found off;
expires max;
}
# Deny access to htaccess and htpasswd files
location ~ /\.ht {
deny all;
}
# Deny access to hidden files (beginning with a period)
location ~ /\. {
access_log off; log_not_found off; deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment