nginx缓存反向代理和清理缓存规则

ZhangJian 2020-02-27 n次浏览 学习记录 编辑

例子 反向代理链接:https://www.88ksk.cn/cgi/qingfeng 清理缓存链接就是:https://www.88ksk.cn/purge/cgi/qingfeng

  location /cgi/qingfeng
  {
      proxy_pass https://www.88ksk.cn;
      proxy_set_header Host www.88ksk.cn;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header REMOTE-HOST $remote_addr;
      add_header X-Cache $upstream_cache_status;
      proxy_ignore_headers Set-Cookie Cache-Control expires;
      proxy_cache cache_one;
      proxy_cache_key $host$uri$is_args$args;
      proxy_cache_valid 200 304 301 302 3h;
      # expires 12h;
  }
  location ~ /purge(/.*) 
  {
    # allow              127.0.0.1;
    # allow              192.168.55.0/24;
    # deny               all;
    proxy_cache_purge  cache_one $host$1$is_args$args;
  }