1

I'm using 3 nginx servers with multiple domains(sites) on each. Each server contains multiple Wordpress sites.

Is it possible to configure Varnish and use separate backends (different IP's) and each backend has multiple domains(sites)?

I've tried to configure Varnish and use multiple backends, but the problem is that domains(sites) on Server-2 and Server-3 doesn't route properly. Frontpage shows up, but sub-pages is routed to Server-1.

I'm using Varnish 4 and this template with some modifications. https://github.com/mattiasgeniar/varnish-4.0-configuration-templates/blob/master/default.vcl

Not sure if round_robin is the right solution because I thought that was for identical servers in sync.

Configuring Varnish 4 and only 1 backend server works. But with multiple backend servers and domains it fails...

Thanks in advance!

1 Answers1

1

In sub vcl_recv, you can use something like this :

if (req.http.host = "domain1.com") {
    set req.backend_hint = domain1;
} elsif (req.http.host = "domain2.com") {
    set req.backend_hint = domain2;
} elsif (req.http.host = "domain3.com") {
    set req.backend_hint = domain3;
}
Sylvain Firmery
  • 331
  • 1
  • 4