Skip to content

Instantly share code, notes, and snippets.

@hqingyi
Created February 2, 2016 09:08
Show Gist options
  • Save hqingyi/cea62724883a4405c143 to your computer and use it in GitHub Desktop.
Save hqingyi/cea62724883a4405c143 to your computer and use it in GitHub Desktop.
nginx config
server {
listen 80;
server_name example.me;
access_log /var/log/example/nginx-access.log;
error_log /var/log/example/nginx-error.log;
location /static/ {
alias /home/django/gaokao/static/;
if ( $uri ~* \.(png|jpe?g|gif|ico|ttf)$ ){
expires 30d;
}
}
location / {
# checks for static file, if not found proxy to app
try_files $uri @proxy_to_app;
}
location @proxy_to_app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://127.0.0.1:8888;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~ /\.git {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment