Install and configure Varnish Cache or Web Accelerator

Varnish is an open source web application accelerator also call as HTTP accelerator or caching HTTP reverse proxy.Varnish is focused exclusively on HTTP,unlike other proxy servers that often support FTP, SMTP and other network protocols.If you need https, then use something like NGINX for 443 and Varnish for 80.2.If you want to essentially redirect all port 80 traffic to port 443, then a simple way would be to write a redirect in your site’s .htaccess file.


Yum install varnish
sudo apt-get install varnish


# List of upstream proxies we trust to set X-Forwarded-For correctly.acl upstream_proxy {  “”;}

backend default {  .host = “”;  .port = “8080”;}

sub vcl_recv {
  # Set the X-Forwarded-For header so the backend can see the original
  # IP address. If one is already set by an upstream proxy, we’ll just re-use that.
  if (client.ip ~ upstream_proxy && req.http.X-Forwarded-For) {
    set req.http.X-Forwarded-For = req.http.X-Forwarded-For;
  } else {
    set req.http.X-Forwarded-For = regsub(client.ip, “:.*”, “”);

sub vcl_hash {
  # URL and hostname/IP are the default components of the vcl_hash
  # implementation. We add more below.
  if ( {
  } else {

  # Include the X-Forward-Proto header, since we want to treat HTTPS
  # requests differently, and make sure this header is always passed
  # properly to the backend server.
  if (req.http.X-Forwarded-Proto) {

  return (hash);
Starting Varnish
# chkconfig –level 345 varnish on
# /etc/init.d/varnish start

# varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T -a

Here traffic on 8080 port forward to a web server listening on port 2000

check for running
# ps auxww | grep varnish
How to Install and Configure Varnish with Apache on Ubuntu 12.04–3

How to Install WordPress, Nginx, PHP, and Varnish on Ubuntu 12.04

Ubuntu 12.04 – Install Varnish 3 in front of Apache 2

Setting Up Varnish & Memcache with Aegir



Posted on August 27, 2013, in LInux Based, Web. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: