varnish相关配置(nginx)
nginx:
upstream.conf
upstream varnish_test{
server 10.11.22.21:8888;
server 10.11.22.22:8888;
keepalive 2000;
)
conf
location @varnish-cache{
proxy_set_header Host a.t.com;
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-Ip $remote_addr;
proxy_set_header Connection "";
proxy_http_version 1.1;
add_header X-Frame-Option "SAMEORIGIN";
if ($http_user_agent !~* "(Android|webOS|iphone|ipad|ipod|blackberry)") {
set $clientType 'oweb';
}
if ($http_user_agent ~* "(Android|webOS|iphone|ipad|ipod|blackberry)") {
set $clientType 'owap';
}
set_by_lua_file $backend 'luafile' $backend;
proxy_pass http://${backend}${varnish_cache_proxy_uri};
}
location ~ ^/path1 {
set $backend 'varnish_test';
set $varnish_cache_proxy_uri '${request_uri}';
try_files $uri @varnish-cache;
}

浙公网安备 33010602011771号