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;

  }

 

posted @ 2020-09-03 19:23  winss  阅读(195)  评论(0)    收藏  举报