How to run Varnish Reverse Cache Proxy in CentOS 5.5 Print

  • 17

HTTP Accelerators have been around for years.  In 2006, Varnish was introduced and unlike other cache proxies like Squid, Varnish was designed from the group up to be an http accelerator also referred to as a caching reverse proxy.

Varnish has an extremely flexible config that allows the system administrator to control how just about any web request is processed and how your web application is cached. While this knowledge base article is meant to be a very basic introduction to Varnish and how to install it, you can extend its features well beyond this article.

NOTE: The below directions assume that you already have Apache Server running on port 80 (which will will be changing):

yum install varnish

Edit /etc/varnish/default.vcl

 

Step 1: Change this:

backend default {

.host = "127.0.0.1";

.port = "80";

}

 

To This:

backend default {

.host = "127.0.0.1";

.port = "8080";

}

 

Step 2: Next edit /etc/sysconfig/varnish and Change this:

 

DAEMON_OPTS="-a :6081 \

-T localhost:6082 \

-f /etc/varnish/default.vcl \

-u varnish -g varnish \

-s file,/var/lib/varnish/varnish_storage.bin,1G"

 

 

To This:

 

DAEMON_OPTS="-a :80 \

-T localhost:6082 \

-f /etc/varnish/default.vcl \

-u varnish -g varnish \

-s file,/var/lib/varnish/varnish_storage.bin,1G"

 

 

Step 3: We are going to want to change the default port that Apache is running on from port 80 to port 8080

Edit /etc/httpd/conf/httpd.conf

Change this:

 

Listen 80

 

 

To This:

 

Listen 8080

 

 

Step 4: Next, we just need to reboot Apache and then start varnish

/etc/init.d/httpd restart

/etc/init.d/varnish start

 

(You'll want to make sure you've set varnish to boot automatically on the next reboot too - "chkconfig varnish on")


Was this answer helpful?

« Back