0

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?

cong yu
  • 11
  • 1
  • Can you show me full error logs? –  Jul 26 '21 at 06:43
  • @anamul Thanks in advance. – cong yu Jul 26 '21 at 07:34
  • I tested again and found that the above is missing proxy_cache cache_one, after adding the static resource cache of both location environments are normal, but still can not log in, I think it is because proxy_hide_header makes the dynamic request lost session, but if I do not use proxy_hide_header will cause the static request contains set-cookie, please ask if there is a way to solve it – cong yu Jul 26 '21 at 07:41
  • @anamul Can I delete only the set-cookie from a static request? – cong yu Jul 26 '21 at 08:20

0 Answers0