Tutorial: Setting up Varnish with Apache.


Posted by Andrew McCombe on Fri Dec 24, 2010


Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. In contrast to other HTTP accelerators, such as Squid, which began life as a client-side cache, or Apache, which is primarily an origin server, Varnish was designed from the ground up as an HTTP accelerator.

Here’s how to set up varnish with Apache.
Tested on Ubuntu 10.04 (Lucid) Server LTS.


1. Install varnish:

2. Configure varnish to serve on 80 and fetch from 8008:

4. Set apache to listen on port 8008:


5. Set all vhosts to listen on port 8008:

Do the same for all other vhosts.

6. Restart Apache and Varnish:

7. Test varnish:

Notice the Varnish headers? There are also a couple of these. Age shows the age of the item in the Varnish cache.

Links

A good set of links can be found here:

Update: 17th Feb 2012

There is also a great set of instructions over at ocaoimh.ie.