redirect in varnish

Pavel Pragin ppragin at SolutionSet.com
Tue Apr 29 00:10:28 CEST 2008


Hello,

At least the address in the URL bar does not change and the new site
doesn't come up. 
I simplified my config file for testing:

backend default {
        set backend.host = "127.0.0.1";
        set backend.port = "8081";
}


sub vcl_recv {

if (req.http.host == "www.tibcocommunity.com") {
                set req.http.host = "www.yahoo.com";
        }
}


-----Original Message-----
From: varnish-misc-bounces at projects.linpro.no
[mailto:varnish-misc-bounces at projects.linpro.no] On Behalf Of Pavel
Pragin
Sent: Monday, April 28, 2008 2:56 PM
To: Poul-Henning Kamp
Cc: varnish-misc at projects.linpro.no
Subject: RE: redirect in varnish 

Hello,
I added the example in the config, but the redirect is not happening.
When I access the site from the browser it does not redirect.
Thanks
         
First part of config:

sub vcl_recv {

if (req.http.host == "www.tibcocommunity.com") {
                set req.http.host = "www.yahoo.com";
        }


              if (req.request == "GET" && req.url ~
"\.(gif|jpg|swf|css)$") {
                lookup;
             }

             if (req.request != "GET" && req.request != "HEAD") {
                 pipe;
             }
             if (req.http.Expect) {
                 pipe;
             }
             if (req.http.Authenticate || req.http.Cookie) {
                 pass;
             }
        remove req.http.X-Forwarded-For;
        set    req.http.X-Forwarded-For = client.ip;

         }

-----Original Message-----
From: phk at critter.freebsd.dk [mailto:phk at critter.freebsd.dk] On Behalf
Of Poul-Henning Kamp
Sent: Monday, April 28, 2008 2:47 PM
To: Pavel Pragin
Cc: varnish-misc at projects.linpro.no
Subject: Re: redirect in varnish 

In message
<DF3A409993D9D940BA8B02F0C396CF8A0153B3E6 at mailserver.form-studios.co
m>, "Pavel Pragin" writes:
>Hello,
>
>Can I add rule to the VCL configuration file to redirect from one URL
to
>another. So if the user goes to http://www.bla.com it will redirect to
>http://www.bla1.com . What will this rule look like and will it be in
>the "sub vcl_recv" section. I would love an example.

	if (req.http.host == "www.bla.com") {
		set req.http.host = "www.bla1.com";
	}

-- 
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.
_______________________________________________
varnish-misc mailing list
varnish-misc at projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc



More information about the varnish-misc mailing list