Difference between revisions of "Setup Varnish - Multiple Domains"

From Brian Nelson Ramblings
Jump to: navigation, search
(Created page with "==Setup Varnish for Multiple Domains== Many times you will have on instance of Varnish on your server but you will have multiple domains on your server. You will need to crea...")
 
(Additional Articles)
Line 29: Line 29:
  
 
===Additional Articles===
 
===Additional Articles===
 +
* [[Setup Varnish Cache]]
 +
* [[Setup Varnish for Magento]]
 +
* [[Setup Varnish for Wordpress]]
 +
* [[Setup Varnish for MediaWiki]]
 +
* [[Setup Varnish - Multiple Ipaddress]]
 +
*[[Script to Clear a Page from Varnish Cache]]

Revision as of 06:33, 19 January 2014

Setup Varnish for Multiple Domains

Many times you will have on instance of Varnish on your server but you will have multiple domains on your server. You will need to create separate backends for each domain.

Below is an example of using two separate domains, with different internal ip.

backend example1 {
    .host = "127.0.0.1";
    .port = "81";
}
backend example2 {
     .host = "127.0.0.2";
     .port = "81";
}
sub vcl_recv {
   if (req.http.host == "example1.com") {
       #You will need the following line only if your backend has multiple virtual host names
       set req.http.host = "example1.com";
       set req.backend = example1;
       return (lookup);
   }
   if (req.http.host == "example2.com") {
       #You will need the following line only if your backend has multiple virtual host names
       set req.http.host = "example2.com";
       set req.backend = example2;
       return (lookup);
   }
}

Additional Articles