varnish

Varnish加速网站图片显示

余生颓废 提交于 2019-12-21 20:06:25
  自从动态生成缩略图上线后,NFS客户端日志时常报无法响应的错误,怀疑是NFS机IO过大,所以想到使用Varnish给NFS机减压,将缩略图存放到内存中,减少读的压力,然后就有了篇博文。 简介:   Varnish是一款高性能的开源HTTP加速器,网上评价比Squid更强,安装配置都很快速,方便。 一、安装: # wget http://repo.varnish-cache.org/source/varnish-2.1.5.tar.gz # tar zxvf varnish-2.1.5.tar.gz cd varnish-2.1.5 # ./configure –prefix=/usr/local/varnish # make && make install 二、配置文件: # cp /usr/local/varnish/etc/varnish/default.vcl /usr/local/varnish/etc/varnish/default.vcl.bak # vi /usr/local/varnish/etc/varnish/default.vcl # 反向代理请求的后端Web服务器ip和端口 backend default { .host = "192.168.1.1"; .port = "80"; } sub vcl_recv { if (req.request !=

How cookies affect Varnish caching?

不羁的心 提交于 2019-12-21 19:56:42
问题 How does Varnish caching affect third-party cookies set by Omniture and first-party cookies set by Google Analytics? So far I've seen opposing opinions, some people say that because the tracking stats are created by JavaScript (which is true), that stripping these Cookies from the request won't affect GA or Omniture. However here they are saying that these softwares set various cookies to track recurring visitors, and so stripping these cookies from the request would essentially count every

Varnish 4 Basic authentication

浪子不回头ぞ 提交于 2019-12-21 04:59:21
问题 I have to cache multiple backend servers, I switch from Nginx to Varnish and finally discover 2 server need to run HTTP Basic Authentication. I try this link http://blog.tenya.me/blog/2011/12/14/varnish-http-authentication and it not work for me (they ran Varnish 3) Is there an easy way to configure Basic Authentication in Varnish 4? 回答1: You can use the VMOD basicauth Install the Varnish VMOD First you need to install it. Download the source from the Git repo for basicauth. Extract into your

Disadvantages to rack-cache vs. Varnish in Heroku cedar stack?

半城伤御伤魂 提交于 2019-12-20 09:39:06
问题 The previous 2 Heroku application stacks came with a Varnish layer which automatically reverse-proxy-cached content based on http headers. The new Heroku cedar stack doesn't have this Varnish layer. Heroku suggests using rack-cache and memcache instead. Does this have disadvantages compared to the previous stacks with the varnish layer? With rack-cache, aren't there fewer servers serving the caching layer, and in a less optimized way? http://devcenter.heroku.com/articles/http-routing http:/

Varnish: cache only specific domain

六眼飞鱼酱① 提交于 2019-12-20 09:02:44
问题 I have been Googling aggressively, but without luck. I'm using Varnish with great results, but I would like to host multiple websites on a single server (Apache), without Varnish caching all of them. Can I specify what websites by URL to cache? Thanks 回答1: (edited after comment) It's req.http.host, so in your vcl file (e.g. default.vcl) do: sub vcl_recv { # dont cache foo.com or bar.com - optional www if (req.http.host ~ "(www\.)?(foo|bar)\.com") { pass; } # cache foobar.com - optional www if

How to write VCL in varnish to do no caching

房东的猫 提交于 2019-12-20 06:18:07
问题 I need to write VCL in Varnish so to prevent caching under certain conditions like cookie value. Any idea how to do that? 回答1: Write and load your own .vcl file to instruct varnish when to cache. By default, requests with cookies will not be cached. You could start with the Varnish tutorial, and don't hesitate to ask a more specific question on this site if you can't make it work... 回答2: Place the following inside your vcl_recv: # as soon as we have a NO_CACHE cookie pass request if (req.http

Having “utm_” in the URL string breaks the $_GET variable in Wordpress

余生长醉 提交于 2019-12-19 06:57:20
问题 First note: This site is hosted on WPEngine (varnish caching), but I can't seem to replicate the issue on another server. We need to be able to access the $_GET php variable on some pages. For testing, I modified our Wordpress header.php to do a var_dump on the very first line. Normally, everything works OK. However if the URL string contains "utm_", every subsequent variable in $_GET is stripped. The extra weird part is that if I am logged in to Wordpress, everything works fine. Our Paypal

Change backend during retry in Varnish 4

狂风中的少年 提交于 2019-12-19 05:59:31
问题 I'd like to be able to change the backend on a retry in Varnish 4. We've got this working on a different (older) application using Varnish 3, but I haven't been able to figure it out for v4, nor find much documentation. The setup we want is to have 2 sets of directors - one for the initial request trying a local server in the same datacenter as varnish because this is way faster, and then only if that fails, pick randomly from a different director for servers in other datacenters. In v3, this

Getting Apache 2.4 access logs to show client IP instead of 127.0.0.1 with Varnish using mod_remoteip

白昼怎懂夜的黑 提交于 2019-12-19 03:36:45
问题 For the life of me, I couldn't get mod_remoteip to get client IPs in my Apache access logs. I'm working on a Virtualmin setup with Varnish 4 installed in front of Apache 2.4.7. How do you get it working? 回答1: I finally got the client IPs in the log and I found the last step here: Here are the steps to getting it to work: Get Varnish to pass a header to Apache with the client IP. You do this by including this bit of code (found in this answer) at the very beginning of your vcl_recv: if (req

varnish 隐藏版本号

▼魔方 西西 提交于 2019-12-18 12:35:14
varnish 隐藏方法: 修改default.vcl配置文件。 找到或添加 vcl_deliver 子程序,代码如下: 1 2 3 4 5 sub vcl_deliver { unset resp.http.Via; //varnish 默认显示版本信息 unset resp.http.X-Varnish; //varnish 默认 set resp.http.Server= "no-server" ; // 后端服务器版本信息,如:Apache /2 .4.4 (Win64) } 前面两行代码是删除varnish默认的信息头,最后一行是修改后端服务器的头,重启varnish后 当然也可以删除 Server 的显示,把 1 set resp.http.Server= "no-server" ; 修改为 1 unset resp.http.Server; 在 vcl_deliver 子程序中是可以任意修改添加响应头信息,所以服务器中有 varnish 则后端服务器无需修改隐藏配置。 来源: https://www.cnblogs.com/fengjian2016/p/5935216.html