Mailing List Archive

Defining varnish + proposals for the FAQ page
As promised, here is a proposal for a new definition of what varnish is for the FAQ (links in <>, changes in bold, comments in []). I did compile some mails exchanged the last days on varnish-dev, credit for this goes to many people.

My mother tongue not being english, there might be quite a few spelling/grammatical errors.

What is varnish ? [new]

Varnish is a HTTP accelerator : a high performance HTTP server to be put in front of a slow one (like apache) to speed up an existing website. Rather than a true reverse proxy (as in <RFC2616>), varnish is a "HTTP surrogate", as defined in the <Edge Architecture Specification> w3c draft. Varnish can be very easily adapted to any website, and <become a reverse proxy> with a few lines of configuration [link to the section in the FAQ, below].

Why bother with Varnish - why not use Squid ? [modified]

Varnish was written from the ground up to be a high performance HTTP accelerator. Squid is a forward proxy that can be configured as a reverse proxy, that, as a side effect, can provide HTTP accelerating features. Besides - Squid is rather old, bloated and designed like computer programs where supposed to be designed in 1980. Please see <ArchitectNotes <http://varnish.projects.linpro.no/wiki/ArchitectNotes> > for details.

How do I configure varnish to act like a classical reverse proxy ? [new]

Here is a sample VCL to do this :

backend default {
set backend.host = "backend.example.com";
set backend.port = "http";
}

sub vcl_recv {

if (req.request != "GET" && req.request != "HEAD") {
pipe;
}
if (req.http.Expect) {
pipe;
}
if (req.http.Authenticate) {
pass;
}
if (req.http.Cache-Control ~ "no-cache") {
pass;
}
lookup;
}

sub vcl_pipe {
pipe;
}

sub vcl_pass {
pass;
}

sub vcl_hash {
set req.hash += req.url;
set req.hash += req.http.host;
hash;
}

sub vcl_hit {
if (!obj.cacheable) {
pass;
}
deliver;
}

sub vcl_miss {
fetch;
}

sub vcl_fetch {
if (!obj.valid) {
error;
}
if (!obj.cacheable) {
pass;
}
if (obj.http.Set-Cookie) {
pass;
}
if (obj.http.Pragma ~ "no-cache" || obj.http.Cache-Control ~ "(no-cache|private)" ) {
pass;
}
insert;
}

sub vcl_deliver {
deliver;
}

sub vcl_timeout {
discard;
}

sub vcl_discard {
discard;
}

What do you think of this ?

Jean-Fran?ois Bustarret
WAT - Responsable technique
http://www.wat.tv

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.linpro.no/pipermail/varnish-misc/attachments/20071123/aee5df0f/attachment.htm
Defining varnish + proposals for the FAQ page [ In reply to ]
In message <53C652A09719C54DA24741D0157CB2695FF9C0 at TFPRDEXS1.tf1.groupetf1.fr>,
"BUSTARRET, Jean-francois" writes:

>How do I configure varnish to act like a classical reverse proxy ? [new]
>
>Here is a sample VCL to do this :

There is one aspect of VCL that I need to communicate better: You
don't need to copy the default VCL into your vcl files.

The way the compiler works is that all definitions of each function
are concatenated, and the default function comes last.

So if for instance you only write in your VCL code:

sub vcl_recv {
if (req.url ~ "[.]exe") {
error 500 "bugger off";
}
}

the compiler will append to this, the default vcl code for vcl_recv.

All the piping/passing of stuff will happen automatically don't
need to put that code in there.

The reason I have written the compiler this way, is so that users
would only need their own specific code.

That way, the default code can change without annoying the users
along the way.

But if you as a user, include the entire default code in your VCL
program, you will have to integrate, by hand, any subsequent
changes to the default VCL code yourself.


Also, if you want to make varnish behave as much as a RFC2616 proxy
as it can, you do not need a VCL program at all, that is, more or
less exactly, what the default VCL code is written against: The
Principle Of Least Astonishment.

Poul-Henning

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
Defining varnish + proposals for the FAQ page [ In reply to ]
> -----Message d'origine-----
> In message
> <53C652A09719C54DA24741D0157CB2695FF9C0 at TFPRDEXS1.tf1.groupetf1.fr>,
> "BUSTARRET, Jean-francois" writes:
>
> >How do I configure varnish to act like a classical reverse proxy ?
> >[new]
> >
> >Here is a sample VCL to do this :
[...]
> Also, if you want to make varnish behave as much as a RFC2616
> proxy as it can, you do not need a VCL program at all, that
> is, more or less exactly, what the default VCL code is
> written against: The Principle Of Least Astonishment.
>
> Poul-Henning

Well, that is not the case : the default VCL (and varnishd) does not support "Cache-control: no-cache/private" and "Pragma: no-cache" (which, IMHO, a "classical reverse proxy" should support)... So you need to add some VCL logic.

Otherwise, I totally agree with "The Principle Of Least Astonishment".

Jean-Fran?ois