changing backend and host header not working
יריב הראל
YARIV-H at yit.co.il
Fri Aug 22 09:47:20 CEST 2014
Thanks Carlos ,
That solved the issue.
[yariv_sig_outlook]
From: Carlos Abalde [mailto:carlos.abalde at gmail.com]
Sent: Friday, August 22, 2014 10:28 AM
To: יריב הראל
Cc: varnish-misc at varnish-cache.org
Subject: Re: changing backend and host header not working
On 22 Aug 2014, at 09:18, יריב הראל <YARIV-H at yit.co.il<mailto:YARIV-H at yit.co.il>> wrote:
Selecting backend and normalizing host header :
sub vcl_recv {
if (req.http.host == "source-qa.example.co.il<http://source-qa.example.co.il/>" || "source-qa-pp.example.co.il<http://source-qa-pp.example.co.il/>" || "qa.example.co.il<http://qa.example.co.il/>") {
set req.http.host = "qa.example.co.il<http://qa.example.co.il/>";
set req.backend = example_qa;
}
}
sub vcl_recv {
if (req.http.host == "source-qa-test.co.il<http://source-qa-test.co.il/>" || "qa-test.co.il<http://qa-test.co.il/>" ) {
set req.http.host = "qa-test.ynet.co.il<http://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<http://source-qa.example.co.il/>" || "source-qa-pp.example.co.il<http://source-qa-pp.example.co.il/>" || "qa.example.co.il<http://qa.example.co.il/>"
The request is always sent to test_other_sites_qa which is the second backend and not the correct one .
Hi,
It seems the second vcl_recv subroutine is matching for every request. You should write:
if (req.http.host == "source-qa.example.co.il<http://source-qa.example.co.il/>" || req.http.host == "source-qa-pp.example.co.il<http://source-qa-pp.example.co.il/>" || req.http.host == "qa.example.co.il<http://qa.example.co.il/>") {
...
if (req.http.host == "source-qa-test.co.il<http://source-qa-test.co.il/>" || req.http.host = "qa-test.co.il<http://qa-test.co.il/>” ) {
...
Cheers,
—
Carlos Abalde.
[Banner]<http://my.ynet.co.il/short/content/2013/ynetnewsletter/index_2.aspx>
Powered by U‑BTech XTRABANNER<http://www.u-btech.com/products/xtrabanner/poweredby>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140822/b3098277/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 10506 bytes
Desc: image001.jpg
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140822/b3098277/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Banner1-d236.jpg
Type: image/jpeg
Size: 50706 bytes
Desc: Banner1-d236.jpg
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20140822/b3098277/attachment-0003.jpg>
More information about the varnish-misc
mailing list