Mailing List Archive

Varnish as Redirection Server
I am using Varnish purely for redirection and cater for below scenario:

1. If http://www.abc.com/url1, redirect to http://www.abc.com/url2
2. If http://www.xyz.com/url1, redirect to http://www.xyz.com/url2

I tried to put the req.http.host variable inside, but Varnish has
error when restarting, I am wondering on how to actually input the
variable into error message?

=========================================
sub vcl_recv {
if (req.url ~ "/url1") {
error 750 "http://" req.http.host "/url2";
}
error 404 "NOT FOUND";
}

sub vcl_error {
if (obj.status == 750) {
set obj.http.Location = obj.response;
set obj.status = 301;
return(deliver);
}
}
=========================================

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish as Redirection Server [ In reply to ]
On 10 April 2012 11:36, Kelvin Loke <kelvin1111111@gmail.com> wrote:
> I am using Varnish purely for redirection and cater for below scenario:

This may be the wrong list on which to state this opinion but, if
you're really *only* doing redirection, I'd look at using nginx for
this task. YMMV, as may other list members, but this does seem to me
to be using Varnish to its own disadvantage.

> 1. If http://www.abc.com/url1, redirect to http://www.abc.com/url2
> 2. If http://www.xyz.com/url1, redirect to http://www.xyz.com/url2
>
> I tried to put the req.http.host variable inside, but Varnish has
> error when restarting

You're going to get more help here if you post the error and its context.

Jonathan
--
Jonathan Matthews
Oxford, London, UK
http://www.jpluscplusm.com/contact.html

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
Re: Varnish as Redirection Server [ In reply to ]
I have actually just figured it out, I need a "+" sign :)

error 750 "http://" + req.http.host + "/url2";


On Tue, Apr 10, 2012 at 6:43 PM, Jonathan Matthews
<contact@jpluscplusm.com> wrote:
> On 10 April 2012 11:36, Kelvin Loke <kelvin1111111@gmail.com> wrote:
>> I am using Varnish purely for redirection and cater for below scenario:
>
> This may be the wrong list on which to state this opinion but, if
> you're really *only* doing redirection, I'd look at using nginx for
> this task. YMMV, as may other list members, but this does seem to me
> to be using Varnish to its own disadvantage.
>
>> 1. If http://www.abc.com/url1, redirect to http://www.abc.com/url2
>> 2. If http://www.xyz.com/url1, redirect to http://www.xyz.com/url2
>>
>> I tried to put the req.http.host variable inside, but Varnish has
>> error when restarting
>
> You're going to get more help here if you post the error and its context.
>
> Jonathan
> --
> Jonathan Matthews
> Oxford, London, UK
> http://www.jpluscplusm.com/contact.html
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc

_______________________________________________
varnish-misc mailing list
varnish-misc@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc