varnish backend redirection based on url

Mattias Geniar mattias at
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:

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;


More information about the varnish-misc mailing list