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.

Installations

Yum install varnish
sudo apt-get install varnish

Configurations

# List of upstream proxies we trust to set X-Forwarded-For correctly.acl

upstream_proxy {  “127.0.0.1”;}

backend default {  .host = “127.0.0.1”;  .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.
  hash_data(req.url);
  if (req.http.host) {
      hash_data(req.http.host);
  } else {
      hash_data(server.ip);
  }

  # 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) {
    hash_data(req.http.X-Forwarded-Proto);
  }

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

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

127.0.0.1:2000 -a 0.0.0.0:8080

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

https://www.digitalocean.com/community/articles/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

https://www.digitalocean.com/community/articles/how-to-install-wordpress

nginx-php-and-varnish-on-ubuntu-12-04

Ubuntu 12.04 – Install Varnish 3 in front of Apache 2

http://pietervogelaar.nl/ubuntu-12-04-install-varnish-3-in-front-of-apache-2/

Setting Up Varnish & Memcache with Aegir

http://community.aegirproject.org/node/388

Refferences
http://www.tecmint.com/install-varnish-cache-web-accelerator/
http://mikkel.hoegh.org/blog/2012/07/24/varnish-as-reverse-proxy-with-nginx

as-web-server-and-ssl-terminator/
https://github.com/revealit/varnishconf/blob/master/revealit.vcl
https://gist.github.com/jeremyjbowers/1542949
https://www.varnish-cache.org/trac/wiki/DebuggingVarnish
https://www.varnish-cache.org/trac/wiki/Introduction

Advertisements

Posted on August 9, 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: