http global config
proxy_cache_path /tmp/nginx/temp/cache_one levels=1:2 keys_zone=cache_one:100m inactive=7d max_size=30g;
proxy_cache_key $scheme://$host$request_uri;
server config
server {
listen 7777;
include /tmp/nginx/conf/open_cache.conf;
location /sample {
include /tmp/nginx/conf/do_cache.conf;
proxy_pass http://192.168.10.184:10071/sample;
}
location /BDS {
include /tmp/nginx/conf/do_cache.conf;
proxy_pass http://192.168.10.184:18741/BDS;
}
}
server {
listen 7788;
include /tmp/nginx/conf/open_cache.conf;
location / {
include /tmp/nginx/conf/do_cache.conf;
proxy_pass http://192.168.10.184:11202;
}
}
open cache config
set $nocache 1;
if ( $request_uri ~ "^/(.*\.)(gif|jpg|png|css|js|flv|ico|swf|woff|svg|ico)$" ) {
set $nocache 0;
}
do cache config
proxy_no_cache $nocache;
proxy_cache_bypass $nocache;
proxy_ignore_headers Set-Cookie;
proxy_hide_header Set-Cookie;
proxy_hide_header SET-COOKIE;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_cache_valid 200 301 206 7d;
expires 30d;
This is a test environment with multiple servers and locations. When I turn on only one location, the cache is fine, but when I turn on all of them, the access cookies are lost in some environments.Is there a way to enable proxy cache for all environments in a large number of servers and locations?