How to run Varnish Reverse Cache Proxy in CentOS 5.5

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")

  • 16 Users Found This Useful
Was this answer helpful?

Related Articles

How to sync the time zone (Linux)

On a VPS server, you don't have access to control the hardware clock directly. To detach your...

How to add the remi repository to CentOS 5.8 / RHEL 5.8 / Redhat

If you are looking for the latest rpm packages for CentOS 5.8 / RHEL / Redhat, the remi...

Configuring Nameservers (DNS) for Outside Domains

If you are not buying a domain from us you will need to manaully configure your nameservers (DNS)...

How to automatically sync your server time clock with rdate in CentOS 5.5

The linux command "rdate" is very useful to quickly sync your server time clock with an NTP...

cPanel Log Locations

cPanel Installation Logs: Code: /var/log/cpanel-install-thread0.log Apache: Code:...