Can Varnish do this?

Bjørn Ruberg bjorn at
Wed Jul 7 09:02:57 CEST 2010

On 07/07/2010 12:10 AM, zabrane Mikael wrote:
> Hi List,
> I'm new to Varnish, so please apologize if the question was already 
> asked before.
> I've a homemade web server running on my intranet. It works like this:
> 1. If an HTTP request arrives without a special header "X-RAWDATA: ...",
> this web server forward the request to the live Web, get the response, 
> and send it back (i.e it plays a role of a basic proxy).
> 2. Now, if a request contains the special header "X-RAWDATA: ...", 
> then the web server will search the response in
> its internal database (complex computations), and send it back.
> Point 2 works very very well. But not point 1 as my web server isn't a 
> true HTTP proxy.
> So, my question is simple:
> Could I tell Varnish to inspect the HTTP headers, and decide:
> a. If the special header "X-RAWDATA: ..." doesn't exists, let the 
> request go to the live Web directly.
> b. Otherwise, forward the request to my web server.

Varnish won't be able to search random, arbitrary web sites as you will 
need to predefine all backend. Each external web server will need to be 
defined as its own backend. If the live web requests are limited to a 
fixed number of external sites, you may define each of them in the VCL.

If that is not the case, an elegant solution for your live web requests 
may be installing a regular proxy and define that as one backend; see 
for inspiration and details :-)

Then, as others have also explained, you'll define two backends - one 
towards the regular proxy (e.g. Squid) and one towards your web server - 
and then make a VCL rule to define the backend based on whether the 
"X-RAWDATA" header is present or not.


More information about the varnish-misc mailing list