Ema has submitted this change and it was merged.
Change subject: text VCL: delay mobile hostname rewrites
......................................................................
text VCL: delay mobile hostname rewrites
cache_text only (cache_mobile unaffected):
This puts off rewriteing the hostname from mobile->desktop until
we're actually sending a backend request to the applayer from a
tier-one backend varnish. Previously it was rewritten on
reception at the frontends. By doing this we avoid the vcl_hash
hack on X-Subdomain and have the cache entries actually
differentiating on the real hostname, which is simpler and saner,
and makes banning of mobile content easier.
Bug: T124166
Change-Id: I6ff7008c88351fcad9d2188764a3202ab2cd80f6
---
M templates/varnish/text-backend.inc.vcl.erb
M templates/varnish/text-common.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
3 files changed, 33 insertions(+), 7 deletions(-)
Approvals:
Ema: Verified; Looks good to me, approved
BBlack: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/templates/varnish/text-backend.inc.vcl.erb
b/templates/varnish/text-backend.inc.vcl.erb
index dfed302..5abc309 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -47,6 +47,26 @@
}
<% end -%>
+<% if @site_tier == "one" && scope.function_hiera(["cluster"]) == "cache_text"
-%>
+sub mobile_hostname_1be_mangle {
+ if (req.http.X-Subdomain) {
+ // Rewrite m.mediawiki.org to mediawiki.org etc
+ if (req.http.host == "m.mediawiki.org") {
+ set bereq.http.host = "www.mediawiki.org";
+ } else if (req.http.host == "m.wikimediafoundation.org") {
+ set bereq.http.host = "wikimediafoundation.org";
+ } else if (req.http.host == "m.wikisource.org") {
+ set bereq.http.host = "wikisource.org";
+ } else if (req.http.host == "m.wikidata.org") {
+ set bereq.http.host = "www.wikidata.org";
+ } else {
+ // Replace <language>.(m|zero).<project>.org by
<language>.<project>.org
+ set bereq.http.host = regsub(req.http.host,
"^([a-zA-Z0-9-]+)\.(m|zero)\.", "\1.");
+ }
+ }
+}
+<% end -%>
+
sub vcl_pass {
<% if @site_tier == "one" -%>
// BITS: legacy bits.wm.o domain support
@@ -54,6 +74,9 @@
call bitscompat_1be_mangle;
return (pass);
}
+<% end -%>
+<% if @site_tier == "one" && scope.function_hiera(["cluster"]) == "cache_text"
-%>
+ call mobile_hostname_1be_mangle;
<% end -%>
call restore_cookie;
}
@@ -66,6 +89,9 @@
return (fetch);
}
<% end -%>
+<% if @site_tier == "one" && scope.function_hiera(["cluster"]) == "cache_text"
-%>
+ call mobile_hostname_1be_mangle;
+<% end -%>
call restore_cookie;
}
diff --git a/templates/varnish/text-common.inc.vcl.erb
b/templates/varnish/text-common.inc.vcl.erb
index b62db40..24c9582 100644
--- a/templates/varnish/text-common.inc.vcl.erb
+++ b/templates/varnish/text-common.inc.vcl.erb
@@ -59,13 +59,6 @@
sub vcl_hash {
// The cookies below represent mobile preferences that can be set for
anonymous users.
if (req.http.X-Subdomain) {
-<% if scope.function_hiera(["cluster"]) == "cache_text" -%>
- // this splits the cache between mobile and desktop variants in
general
- // the text-cluster conditional is temporary, to avoid
effectively wiping the primary cache
- // on the legacy mobile cluster on deploy
- hash_data("Mobile-Subdomain");
-<% end -%>
-
// Split the cache for the images-disabled variant of the
mobile site.
if (req.http.X-Orig-Cookie ~ "(^|;\s*)disableImages=1" ||
req.http.Cookie ~ "(^|;\s*)disableImages=1") {
hash_data("disableImages=1");
diff --git a/templates/varnish/text-frontend.inc.vcl.erb
b/templates/varnish/text-frontend.inc.vcl.erb
index 78e8604..05b614c 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -183,6 +183,12 @@
call tag_carrier;
}
+<% if scope.function_hiera(["cluster"]) == "cache_mobile" -%>
+ // in the text cluster this is now done on tier-one
+ // bereq to the applayer only, but it's preserved for
+ // the mobile cluster here so that we don't
+ // effectively invalidate the whole mobile cache on
+ // cache_mobile machines in the process...
// Rewrite m.mediawiki.org to mediawiki.org etc
if (req.http.host == "m.mediawiki.org") {
set req.http.host = "www.mediawiki.org";
@@ -196,6 +202,7 @@
// Replace <language>.(m|zero).<project>.org by
<language>.<project>.org
set req.http.host = regsub(req.http.host,
"^([a-zA-Z0-9-]+)\.(m|zero)\.", "\1.");
}
+<% end -%>
}
}
--
To view, visit https://gerrit.wikimedia.org/r/265271
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I6ff7008c88351fcad9d2188764a3202ab2cd80f6
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: BBlack <[email protected]>
Gerrit-Reviewer: BBlack <[email protected]>
Gerrit-Reviewer: Ema <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits