varnish backend redirection based on url
Shibashish
shib4u at gmail.com
Wed Aug 3 18:29:54 CEST 2011
On Wed, Jul 27, 2011 at 5:18 PM, Mattias Geniar <mattias at nucleus.be> wrote:
> > 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
>
This doesn't work...
if (req.http.host == "www.domain.com" && req.url ~ "^/hi$") {
set req.backend = hiserver; }
elseif (req.http.host == "www.domain.com" && req.url ~ "^/$") {
# if /hi is not specified, i.e go to /
set req.backend = enserver; }
else {set req.backend = default; } #
all other sites go here
All requests are going to "default" or "enserver".
Kindly help, thanks in advance.
ShiB.
while ( ! ( succeed = try() ) );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20110803/fc2ccbf8/attachment-0003.html>
More information about the varnish-misc
mailing list