Skip to content

Instantly share code, notes, and snippets.

@youyo
Last active December 11, 2015 18:38
Show Gist options
  • Save youyo/4643055 to your computer and use it in GitHub Desktop.
Save youyo/4643055 to your computer and use it in GitHub Desktop.
http {
# DNS resolver
resolver 127.0.0.1;
proxy_cache_path /var/cache/nginx/static_file_cache levels=1:2 keys_zone=cache_static_file:10m inactive=7d max_size=100m;
proxy_temp_path /var/cache/nginx/temp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
server {
listen 8181;
proxy_redirect off;
set $do_not_cache 0;
if ($request_method != GET) {
set $do_not_cache 1;
}
if ($uri !~* "\.(jpg|png|gif|jpeg|css|js|swf|pdf|html|htm)$") {
set $do_not_cache 1;
}
proxy_no_cache $do_not_cache;
proxy_cache_bypass $do_not_cache;
proxy_cache cache_static_file;
proxy_cache_key $scheme$host$uri$is_args$args;
proxy_cache_valid 200 302 304 1d;
proxy_cache_valid any 10m;
location / {
proxy_pass $scheme://$http_host$request_uri;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment