Skip to content

Instantly share code, notes, and snippets.

@notsobad
Created February 26, 2014 03:43
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 notsobad/9223145 to your computer and use it in GitHub Desktop.
Save notsobad/9223145 to your computer and use it in GitHub Desktop.
Proxy cache sample.
proxy_cache_path /data/proxy_cache levels=1:2 keys_zone=ui-cache:10m max_size=2048m;
server {
# api proxy
listen 80;
# Force cache post data for 3 days.
location /xxxx.php {
proxy_cache_key "$scheme://$host$request_uri|$request_body";
proxy_cache_valid 200 3d;
proxy_cache ui-cache;
proxy_cache_methods POST;
proxy_pass http://127.0.0.1:8200/xxxx.php;
}
# Cache url with basic auth.
location / {
proxy_set_header Host "notsobad.me";
proxy_cache_key "$scheme://$host$request_uri|$http_authorization";
proxy_cache ui-cache;
proxy_pass http://10.10.10.10/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment