Varnish前端代理Drupal的配置以及Jenkins
2012-09-29 10:09
447 查看
Varnish前端代理Drupal的配置以及Jenkins
鉴于Varnish使用以及教程都较少,所以特将Varnish作为drupal的前端代理配置贴出来,供大家参考使用。顺便设置了Jenkins的代理转发,如果要启动Jenkins,请注意端口号。Apache/Nginx只需监听127.0.0.1的80端口即可,Varnish监听公网IP的80端口,负责转发请求。
文件中附带了Round-Robin负载均衡的设置,如果有多个服务器,可以参考之,文件默认位置:/etc/varnish/default.vcl。
backend default { .host = "127.0.0.1"; .port = "80"; } backend jenkins { .host = "127.0.0.1"; .port = "8100"; } ############################## ## Round Robin Backend # ############################## #backend rr1 { # .host = "192.168.8.1"; # .port = "80"; # .probe = { .url = "/ee.txt"; # .interval = 20 s; # .timeout = 10 s; # .window = 10; # .threshold = 2; # } #} #backend rr2 { # .host = "192.168.8.2"; # .port = "80"; # .probe = { .url = "/ee.txt"; # .interval = 20 s; # .timeout = 10 s; # .window = 10; # .threshold = 2; # } #} #director zcn round-robin { # { # .backend = rr1; # } # { # .backend = rr2; # } #} ############################## # # Below is a commented-out copy of the default VCL logic. If you # redefine any of these subroutines, the built-in logic will be # appended to your code. sub vcl_recv { #jenkins if (req.url ~ "^/jenkins") { set req.backend = jenkins; } #if (req.http.host ~ "^domain.com$") { # set req.backend = default; #} # Download large files if (req.url ~ "\.(csv|pdf|xml|rar|zip)") { return(pipe); } # Prevent cache if (req.url ~ "^logout$" || req.url ~ "^/cron.php") { return (pass); } # Remove cookies set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(_gscu_|_gscs_|_gscbrs_|zinch_flag_like|zt|paq_cookietime)[^;]*", ""); set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", ""); if (req.http.Cookie ~ "^\s*$") { remove req.http.Cookie; } if (req.url ~ "\.(jpg|png|css|js|ico|gz|tgz|bz2|tbz|gif)$") { remove req.http.cookie; } if (req.restarts == 0) { if (req.http.x-forwarded-for) { set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip; } else { set req.http.X-Forwarded-For = client.ip; } } if (req.request != "GET" && req.request != "HEAD" && req.request != "PUT" && req.request != "POST" && req.request != "TRACE" && req.request != "OPTIONS" && req.request != "DELETE") { /* Non-RFC2616 or CONNECT which is weird. */ return (pipe); } if (req.request != "GET" && req.request != "HEAD") { /* We only deal with GET and HEAD by default */ return (pass); } if (req.http.Authorization || req.http.Cookie) { /* Not cacheable by default */ return (pass); } return (lookup); } sub vcl_deliver { # Add http header to indicate if cache hit if (obj.hits > 0) { set resp.http.X-Cache = "HIT"; } else { set resp.http.X-Cache = "MISS"; } }
顺便公布几个Varnish常用的技巧命令:
测试VCL
/usr/sbin/varnishd -F -f /etc/varnish/active.vcl -u varnish -g varnish -a :81 -n test_instance -s file,/tmp/varnish_storage.bin,10M
清除所有缓存
ban.url .*
载入新VCL以及使用
vcl.load load01 /etc/varnish/new.vcl; vcl.use load01
其他参考文章:
Varnish构建高负载Drupal网站 – 高级篇
高负载网站之Varnish与Drupal – 基本篇
相关文章推荐
- 构建Varnish缓存代理服务器以及反向代理Nginx服务配置详解
- 解决git无法clone提示443以及配置git代理方法
- RedHat AS4 Update7 安装nginx及配置前端代理
- Ubuntu 搭建Jenkins服务器以及配置邮件工程全解
- Spring 代理对象,cglib,jdk的问题思考,AOP 配置注解拦截 的一些问题.为什么不要注解在接口,以及抽象方法.
- Jenkins 安装以及配置全过程(一)
- nginx 配置静态web服务器以及反向代理服务器的一些问题
- 转贴自 : Varnish反向代理伺服器安裝配置
- 解决nginx作为前端代理默认访问一个80端口虚拟主机配置问题
- nginx反向代理cas server之1:多个cas server负载均衡配置以及ssl配置
- 【树莓派】Squid代理以及白名单配置
- varnish 4.0 缓存代理配置
- 关于更新sdk用的代理设置,以及hosts配置的了解
- nginx配置虚拟域名以及代理
- varnish 简介以及实用配置
- 20170731jenkins安装、配置以及使用(二)
- Flume安装&以及常用的代理配置
- 【前端】vue.js环境配置以及实例运行简明教程
- Jenkins 一: 环境安装以及配置
- nginx 做前端代理时proxy参数配置