V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
xiaoz
1.03D
V2EX  ›  NGINX

Nginx 反向代理怎样设置某个目录不缓存?

  •  
  •   xiaoz ·
    helloxz · May 25, 2018 · 5067 views
    This topic created in 2907 days ago, the information mentioned may be changed or developed.

    目前的反代配置如下:

    proxy_cache_path /data/caches/xxx.com levels=1:2 keys_zone=gravatar:50m inactive=30m max_size=50m;
    server {
      	listen 80;
        server_name xxx.com;
        
        
        charset utf-8,gbk;
            location / {
               proxy_pass http://cn.gravatar.com;
               proxy_redirect off;
               proxy_set_header X-Real-IP $remote_addr;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_cache gravatar;
               proxy_cache_valid  200 304 301 7d;
               proxy_cache_valid  500 502 503 504 0s;
               proxy_cache_valid any 7d;
               proxy_cache_min_uses 1;
               expires 12h;
        }
    }
    

    这样的配置是带有全局缓存的,假如我只希望 xxx.com/admin 这个路径不带有缓存,该如何配置?

    3 replies    2018-05-25 16:34:36 +08:00
    Lax
        1
    Lax  
       May 25, 2018   ❤️ 1
    再加一个 location
    location /admin {
    proxy_pass ...;
    }
    hisys
        2
    hisys  
       May 25, 2018   ❤️ 1
    在一楼基础上添加一行:
    proxy_cache_valid any 0s;
    xiaoz
        3
    xiaoz  
    OP
       May 25, 2018
    @Lax
    @hisys
    好的,谢谢大佬,我试试。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   899 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 19:46 · PVG 03:46 · LAX 12:46 · JFK 15:46
    ♥ Do have faith in what you're doing.