changing backend and host header not working

יריב הראל YARIV-H at yit.co.il
Fri Aug 22 09:18:51 CEST 2014



Hi ,

First some info :
varnish-3.0.3-1.el5.centos.x86_64
CentOS release 6.3 (Final)
Linux xxxxxx  2.6.32-279.9.1.el6.x86_64 #1 SMP Tue Sep 25 21:43:11 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

varnishd -P /var/run/varnish.pid -a :80 -f /etc/varnish/default.vcl
-T 127.0.0.1:6082 -t 86400 -w 50,1000,120 -u varnish -g varnish -S /etc/varnish/secret
-s file,/var/lib/varnish/varnish_storage.bin,256M
-p sess_timeout 305
-p http_req_hdr_len 16384
-p http_req_size 65536
-p http_resp_hdr_len 16384
-p http_resp_size 65536
-p http_gzip_support off
-p pipe_timeout 120
-p sess_workspace 131072
-p http_max_hdr 256

I’m trying to do virtual hosting  via changing backend based on host header and at the same time normalize the host header :

Two backend statements :


backend example_qa {
        .host = "192.xxx.xxx.xxx";
        .port = "80";
        .first_byte_timeout = 1200s;
        .connect_timeout = 1200s;
        .between_bytes_timeout = 1200s;

}



backend test_other_sites_qa {
        .host = "192.xxx.xxx.xxx";
        .port = "80";
        .first_byte_timeout = 1200s;
        .connect_timeout = 1200s;
        .between_bytes_timeout = 1200s;

}



Selecting backend and normalizing host header :

sub vcl_recv {
        if (req.http.host == "source-qa.example.co.il" || "source-qa-pp.example.co.il" || "qa.example.co.il") {
                set req.http.host = "qa.example.co.il";
                set req.backend = example_qa;
}
}


sub vcl_recv {
                if (req.http.host == "source-qa-test.co.il" || "qa-test.co.il" ) {
                                set req.http.host = "qa-test.ynet.co.il";
                                set req.backend = test_other_sites_qa;
}
}



Now the problem is that  when I send a request with one of the host headers  "source-qa.example.co.il" || "source-qa-pp.example.co.il" || "qa.example.co.il"

The request is always sent to  test_other_sites_qa which is the second backend and not the correct one .

Thanks




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140822/54a38e81/attachment.html>


More information about the varnish-misc mailing list