varnish backend redirection based on url

Mattias Geniar mattias at nucleus.be
Wed Jul 27 13:48:11 CEST 2011


> I have a main website running which has now been translated to
different languages. The different language sites are running on
different backend servers. I want to redirect/distribute traffic to
backends based on the url without rewriting the url/host.

That's possible, you can set a different backend based on a (part of
the) URL. Have a look here:
https://www.varnish-cache.org/docs/trunk/tutorial/advanced_backend_serve
rs.html

Specifically, you'd want something as:
sub vcl_recv {
    if (req.url ~ "^/en/") {
        set req.backend = backend_en;
    } elseif (req.url  ~ "^/hi/" {
        set req.backend = backend_hi;
    }
}

Regards,
Mattias




More information about the varnish-misc mailing list