I have a server hosting 3 subdomains of the same domain, each with it's own IP. I need to setup varnish in front of apache for the reason that I server A LOT of small images and varnish works miracles.
Since the server is not named yet (the DNS point to the old one), I do the comparison with IPs (I do not know if this is the reason I get garbage)....
I've set apache on port 0.0.0.0:81 from cPanel and made backends on the default.vcl like so:
backend name1 {
.host = "x1.y2.z3.w4";
.port = "81";
}
backend name2 {
.host = "x5.y6.z7.w8";
.port = "81";
}
and so on, for all the subdomains
All the examples are saying :
put :
if (req.http.host ~ "x1.y2.z3.w4") {
set req.backend = name1;
} else {
set req.backend = name2;
}
which I add to a new vcl_recv subroutine definition like so:
sub vcl_recv {
if (req.http.host ~ "x1.y2.z3.w4") {
set req.backend = name1;
} else {
set req.backend = name2;
}
return(lookup);
}
The result is that I get something only if I put specifically the x5.y6.z7.w8 IP (the exception to the above rule) and everything else redirects me to the default website cpanel page in error that it does not find anything.
the daemon options definition in the sysconfig/varnish file is:
DAEMON_OPTS="-a 0.0.0.0:80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-u varnish -g varnish \
-s malloc,7G \
-p thread_pool_add_delay=1 \
-p thread_pools=4 \
-p thread_pool_min=200 \
-p thread_pool_max=4000 \
-p session_linger=50 \
"
Needless to say that both ips work when I access them through apache's port 81.
Any ideas of what may go wrong? I am a total n00b in varnish VCL and any help or pointer is most welcome!
THANKS