redirect in varnish

Pavel Pragin ppragin at
Mon Apr 28 23:56:24 CEST 2008

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.
First part of config:

sub vcl_recv {

if ( == "") {
                set = "";

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

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


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

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

	if ( == "") {
		set = "";

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

More information about the varnish-misc mailing list