Yurik has uploaded a new change for review.
https://gerrit.wikimedia.org/r/93006
Change subject: Add more zero values to analytics header
......................................................................
Add more zero values to analytics header
In order to improve analytics data, enhance X-Analytics header
with the determined client IP and an optional trusted proxy name
that the client might have gone through (e.g. OPERA)
Change-Id: Iebc24dced799e78f32e5fb619f77fb2d6eabfa45
---
M templates/varnish/mobile-frontend.inc.vcl.erb
M templates/varnish/zero.inc.vcl.erb
2 files changed, 20 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/puppet
refs/changes/06/93006/1
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb
b/templates/varnish/mobile-frontend.inc.vcl.erb
index 9fe4009..dfa0778 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -9,15 +9,22 @@
/* This call will always set the following req.http values:
X-Subdomain = M or ZERO
X-DfltLang = en|fr|ru|...
- This value is only set if the carrier has been successfully
detected
+ These value are set only if the carrier has been successfully
detected
X-CS = "502-13"
+ X-TrueIp = "1.1.1.1"
+ X-TrustedProxy = "OPERA" (is set only if passed through
a known proxy)
*/
call tag_carrier;
/* Assemble X-Analytics header */
if (req.http.X-CS) {
- set req.http.X-Analytics = "zero=" + req.http.X-CS;
+ set req.http.X-Analytics = "zero=" + req.http.X-CS +
";ip=" + X-TrueIp;
+ if (req.http.X-TrustedProxy) {
+ set req.http.X-Analytics = req.http.X-Analytics
+ ";proxy=" + req.http.X-TrustedProxy;
+ }
}
+ unset req.http.X-TrueIp;
+ unset req.http.X-TrustedProxy;
} else {
set req.http.X-Subdomain = "M";
}
diff --git a/templates/varnish/zero.inc.vcl.erb
b/templates/varnish/zero.inc.vcl.erb
index 26c4253..db14785 100644
--- a/templates/varnish/zero.inc.vcl.erb
+++ b/templates/varnish/zero.inc.vcl.erb
@@ -11,7 +11,11 @@
// Note that currently, tag_carrier is *only* called when the request
is not
// via HTTPS (check for X-Forwarded-Proto at the top of vcl_recv in
mobile-frontend.vcl).
- set req.http.X-CS2 = netmapper.map("zero", "" + client.ip);
+ // The X-TrustedProxy and X-TrueIp headers are used as temporary values
to pass to analytics
+ // And will be unset by the end of the vcl_recv()
+ unset req.http.X-TrustedProxy;
+ set req.http.X-TrueIp = "" + client.ip;
+ set req.http.X-CS2 = netmapper.map("zero", req.http.X-TrueIp);
if (req.restarts == 0 && (req.http.X-CS2 == "-OPERA" || req.http.X-CS2
== "-TEST")) {
// Elsewhere in the VCL, the frontend appends client.ip to XFF
for when
@@ -25,9 +29,14 @@
// ^ X-S-XFF now contains XFF without its final item, which was
client.ip.
if (req.http.X-Stripped-XFF != "") { // If one or more IPs
remain in X-S-XFF
+
+ // A trusted proxy has been detected, record its name
for analytics
+ set req.http.X-TrustedProxy = regsub(req.http.X-CS2,
"^-", "");
+
// Strip away any leading IPs, such that the result of
regsub() is the
// rightmost (or only) remaining IP, and use that to
re-set X-CS2:
- set req.http.X-CS2 = netmapper.map("zero",
regsub(req.http.X-Stripped-XFF, "^.*, ?", ""));
+ set req.http.X-TrueIp = regsub(req.http.X-Stripped-XFF,
"^.*, ?", "");
+ set req.http.X-CS2 = netmapper.map("zero",
req.http.X-TrueIp);
}
unset req.http.X-Stripped-XFF; // clean up our temp var
}
--
To view, visit https://gerrit.wikimedia.org/r/93006
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebc24dced799e78f32e5fb619f77fb2d6eabfa45
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Yurik <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits