Strange problem with url redirecting when clicking on a link

Damien Sarazin damien.sarazin at smile.fr
Mon Aug 4 11:43:11 CEST 2008


Hello,

i replaced Squid by Varnish on web sites that are in production (like a 
lot of people here :)), and i haven't had any problems with those until 
the last one.

The issue is that when the client clicked on a link, the url was 
redirect towards the port 81 and given that varnish is listening on the 
port 80 the pages were not normally displayed.

I don't understand how this could happen since when i was browsing 
myself i never had the same problem. However i looked in the varnishlog 
and here is the result :

varnishncsa -c -r /var/log/varnish/diagnostic-port | grep ":81"

213.56.83.241 - - [01/Aug/2008:14:27:46 +0200] "GET 
http://www.website.com:81/football/fil-info/brann-ou-ventspils-pour-l-om-178141/ 
HTTP/1.1" 200 92149 "http://www.website.com/football/" "Mozilla/4.0 
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 
2.0.50727)"

213.56.83.241 - - [01/Aug/2008:14:29:12 +0200] "GET 
http://www.website.com:81/football HTTP/1.1" 301 239 "-" "Mozilla/4.0 
(compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 
2.0.50727)"

213.56.83.241 - - [01/Aug/2008:14:29:12 +0200] "GET 
http://www.website.com:81/football/ HTTP/1.1" 200 134824 "-" 
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; 
.NET CLR 2.0.50727)"

Apache is listening on the same OS on the port 81, but transactions are 
not allowed on this port by the firewall. (The firewall is not on this 
computer).

i am using the trunk version 2945.

Varnish is listening on the 2 interfaces of the computer.

The default file looks like this :

VARNISH_LISTEN_ADDRESS=
VARNISH_LISTEN_PORT=80

VARNISH_ADMIN_LISTEN_ADDRESS=localhost
VARNISH_ADMIN_LISTEN_PORT=6082

VARNISH_MIN_THREADS=1

VARNISH_MAX_THREADS=1000

VARNISH_THREAD_TIMEOUT=120

VARNISH_STORAGE_FILE=/var/varnish/$INSTANCE/varnish_storage.bin

VARNISH_STORAGE_SIZE=5G

VARNISH_STORAGE="file,${VARNISH_STORAGE_FILE},${VARNISH_STORAGE_SIZE}"

VARNISH_TTL=0


The VCL file :

backend default {
        .host = "localhost";
        .port = "81";
}


sub vcl_recv {
        remove req.http.X-Forwarded-For;
        set    req.http.X-Forwarded-For = client.ip;

        set req.backend = default;


   if (req.request == "PURGE") {
           if (!client.ip ~ purge) {
                    error 405 "Not allowed.";
           }
              lookup;
   }



   if (req.request != "GET" && req.request != "HEAD" && req.request != 
"PUT" && req.request != "POST" && req.request != "TRACE" && req.request 
!= "OPTIONS" && req.request != "DELETE") {
        pipe;
   }


   if (req.url ~ "\.(css|gif|jpg|jpeg|png|ico|swf|js)$") {
        lookup;
   }

   if (req.http.Expect) {
        pipe;
   }

   if (req.http.Authenticate) {
       pass;
   }  

  
   if (req.request != "GET" && req.request != "HEAD") {
        pass;
   }


    if (req.http.Cache-Control ~ "no-cache") {
       pass;
    }


    set req.grace = 30s;

    lookup;
}


sub vcl_hash {
        set req.hash += req.url;
        set req.hash += req.http.host;
        hash;
}


sub vcl_hit {
        if (!obj.cacheable) {
                pass;
        }


        if (req.request == "PURGE") {
            set obj.ttl = 0s;
            error 200 "Purged.";
        }


        set obj.http.X-Cache = "HIT";

        deliver;
}



sub vcl_fetch {


        if (!obj.valid) {
                error;
        }

        if (!obj.cacheable) {
                pass;
        }

        if (obj.http.Set-Cookie) {
                pass;
        }


        if (obj.http.Pragma ~ "no-cache" || obj.http.Cache-Control ~ 
"(no-cache|no-store|private)") {
                pass;
        }

 
        set obj.grace         if (req.http.Authorization && 
!obj.http.Cache-Control ~ "public") {
                pass;
        }

        insert;
}


sub vcl_deliver {

        set resp.http.Via = "Varnish";

        deliver;
}

 
I have the same configuration, except for  the "VARNISH_LISTEN_ADDRESS=" 
line, on other sites and this url redirecting on port 81 never happened 
before. And as i said before, while i was browsing myself on this 
website, i didn't encounter this issue.
I don't know if it is random, if it comes from the browser of the 
client, from the loadbalancer, from the max_threads or from another thing.

Have you any idea about this ?

Before trying to add a rule that searches for ":81" and remove it in the 
url, i wanted to have your opinion and know if someone had already seen 
this problem.


Best regards,

-- 
Damien Sarazin




More information about the varnish-misc mailing list