redirect in varnish

Poul-Henning Kamp phk at phk.freebsd.dk
Wed Aug 6 16:28:01 CEST 2008


In message <20080806141824.GA84142 at fupp.net>, Anders Nordby writes:
>Hi,
>
>On Mon, Apr 28, 2008 at 09:47:16PM +0000, Poul-Henning Kamp wrote:
>> 	if (req.http.host == "www.bla.com") {
>> 		set req.http.host = "www.bla1.com";
>> 	}
>
>Trying a VCL like this (this is my entire VCL, used as an example), I do
>not get a redirect:
>
>backend default {
>        .host = "192.168.0.1";
>        .port = "80";
>}
>
>sub vcl_recv {
>        set req.http.host = "www.foobar.no";
>        set req.http.url = "/";
>        lookup;
>}
>
>Instead of doing a redirect, it fetches pages off the default backend.
>Why? How do I redirect to another URL on a different host, not served by
>Varnish?

You need to define that host as a backend.

>PS: Another thing, the first backend seems to become the default one,
>even though there is no backend called "default". Shouldn't it respond
>with 503 Service Unavailable instead? I like to control what is default
>and not.

No, the first backend in the VCL is your default, no matter what it
is called.

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



More information about the varnish-misc mailing list