Multisites and Varnish setup
-
Hello everyone.
I have a WordPress multisite with around 100 sites, many of which use their own domains mapped using Donncha’s plugin. Users map an A record in their DNS manager to our dedicated IP.
I want to install Varnish and I have this running on a similar setup but it only has 2 sub sites with their own domain:
ports.conf
# NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080
Listen 127.0.0.1:8000/etc/apache2/sites-enabled/zz-mass-hosting
NameVirtualHost 127.0.0.1:8080
<VirtualHost 127.0.0.1:8080>/etc/apache2/sites-enabled/zz-mass-hosting.212.110.XXX.XXX ** is the multisite_ip
NameVirtualHost 127.0.0.1:8000
<VirtualHost 127.0.0.1:8000>
ServerName mysite.co.uk:8000/etc/default/varnish points
DAEMON_OPTS points to the 2 ips on port 80
I have set up the vcl with 2 backends:
backend default {
.host = “127.0.0.1”;
.port = “8080”;
}# For 2nd IP Address setting Apache Backend to 127.0.0.1:8000
backend mysite {
.host = “127.0.0.1”;
.port = “8000”;
}On my test installation I only have 2 sites mapped to their own domains, so I have this:
# choose a backend depending on domain
if (req.http.host ~ “myothersite.co.uk”) {
set req.backend = mysite;
}
if (req.http.host ~ “andanotherone.com”) {
set req.backend = mysite;
}else{
set req.backend = default;
}Seems to be working OK right now.
But on the new installation I have a heck of a lot of sites to map, so my question is whether there’s a snappy way around this without lots of typing or manual intervention each time a new site is mapped to its own domain (I don’t always know this)?
Alternatives on a postcard.
Thanks in anticipation …
- The topic ‘Multisites and Varnish setup’ is closed to new replies.