BBlack has submitted this change and it was merged.

Change subject: Handle the change with netmapper and varnish 3.0.4 & later
......................................................................


Handle the change with netmapper and varnish 3.0.4 & later

Varnish has changed the way they handle the result of the vmod
function calls: after 3.0.4, a vmod function that returns null is
automatically changed to return an empty string.

This has also been verified by by Brandon, who found this related bug
https://www.varnish-cache.org/trac/ticket/1218

Now, with the future migration to 3.0.5 and beyond, netmapper will
always sets the resulting header as "", not NULL, and
if(response) will always be true.

We could obviously change all the other code to check for =="",
but I think keeping implicit bool-ness of headers is cleaner.

Change-Id: I7cd4518df540467b84a6ea4e5c246623a0768024
---
M templates/varnish/zero.inc.vcl.erb
1 file changed, 10 insertions(+), 0 deletions(-)

Approvals:
  BBlack: Verified; Looks good to me, approved



diff --git a/templates/varnish/zero.inc.vcl.erb 
b/templates/varnish/zero.inc.vcl.erb
index d3f749d..a8e4a72 100644
--- a/templates/varnish/zero.inc.vcl.erb
+++ b/templates/varnish/zero.inc.vcl.erb
@@ -13,6 +13,11 @@
        //  via HTTPS (check for X-Forwarded-Proto at the top of vcl_recv in 
mobile-frontend.vcl).
 
        set req.http.X-Forwarded-By = netmapper.map("proxies", "" + client.ip);
+       // netmapper returns an empty string when not found, not NULL,
+       // need to normalize before using implicit bool cast
+       if (req.http.X-Forwarded-By == "") {
+               unset req.http.X-Forwarded-By;
+       }
 
        if (!req.http.X-Forwarded-By) {
                // direct request or unknown proxy
@@ -41,6 +46,11 @@
                unset req.http.X-Stripped-XFF; // clean up our temp var
        }
 
+       // Normalize X-CS2 to be used as bool
+       if (req.http.X-CS2 == "") {
+               unset req.http.X-CS2;
+       }
+
        if ( req.http.host ~ "^([a-zA-Z0-9-]+\.)?zero\." ) {
                set req.http.X-Subdomain = "ZERO";
        } else {

-- 
To view, visit https://gerrit.wikimedia.org/r/102887
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I7cd4518df540467b84a6ea4e5c246623a0768024
Gerrit-PatchSet: 4
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Dr0ptp4kt <[email protected]>
Gerrit-Reviewer: Faidon Liambotis <[email protected]>
Gerrit-Reviewer: Mark Bergsma <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to