Mark Bergsma has submitted this change and it was merged. Change subject: Unified default lang redirect from m. & zero. Adding three carriers for testing, too. ......................................................................
Unified default lang redirect from m. & zero. Adding three carriers for testing, too. This is a compile fix for Change-Id: Ifda2dcabaa08f5df7b22b3b1d726f21882bbca36 * Default language for the carrier is now set in one location * XL Indonesia is changed to "id" default language * Old code did NOT redirect unknown carrier zero.wiki to en.zero.wiki. Now redirecting. * Refactored to support default relative redirect path for direct zero. and m. access from partners. * All partner direct access to zero. and m. going to default (language options selection page). * Adding three additional carriers for testing. Change-Id: I8fb36d26d437ad21f240820d8a949543fc6577e6 --- M templates/varnish/mobile-frontend.inc.vcl.erb 1 file changed, 81 insertions(+), 46 deletions(-) Approvals: Mark Bergsma: Looks good to me, approved jenkins-bot: Verified diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb b/templates/varnish/mobile-frontend.inc.vcl.erb index a4e1bdc..228662d 100644 --- a/templates/varnish/mobile-frontend.inc.vcl.erb +++ b/templates/varnish/mobile-frontend.inc.vcl.erb @@ -313,6 +313,27 @@ "89.188.224.136"/29; } +acl carrier_vimpelcom_mobilink_pakistan { + "119.160.125.0"/27; + "119.160.126.97"/28; + "119.160.126.129"/25; +} + +acl carrier_orange_meditel_morocco { + "41.92.0.0"/18; + "41.92.64.0"/19; + "41.214.192.0"/18; + "197.153.0.0"/16; + "197.247.0.0"/16; +} + +acl carrier_central_african_republic { + "41.223.184.1"/32; + "41.223.184.2"/31; + "41.223.184.148"/30; + "41.223.184.152"/30; +} + # for test.* routing, FIXME backend test_wikipedia { .host = "srv193.pmtpa.wmnet"; @@ -335,11 +356,23 @@ set req.http.X-Subdomain = "M"; } + // go to english by default + set req.http.X-DfltLang = "en"; + set req.http.X-DfltPage = "/wiki/Special:ZeroRatedMobileAccess"; + /* Please keep this list alphabetized by the ACL variable */ if (client.ip ~ carrier_celcom_malaysia) { if (req.http.X-Subdomain == "ZERO") { set req.http.X-Carrier = "Celcom Malaysia"; set req.http.X-CS = "502-13"; + } + } else if (client.ip ~ carrier_central_african_republic) { + set req.http.X-DfltLang = "fr"; + if (req.http.X-Subdomain == "M") { + if (req.http.host ~ "(^(fr|ar|sg|en|es|zh|ar|ha|ln|eo)\.m|^m)\.([a-zA-Z0-9-]+)\.org") { + set req.http.X-Carrier = "Orange Central African Republic"; + set req.http.X-CS = "623-01"; + } } } else if (client.ip ~ carrier_dialog_sri_lanka) { if (req.http.X-Subdomain == "ZERO") { @@ -354,11 +387,13 @@ } } } else if (client.ip ~ carrier_dtac) { + set req.http.X-DfltLang = "th"; if (req.http.X-Subdomain == "ZERO") { set req.http.X-Carrier = "DTAC"; set req.http.X-CS = "520-18"; } } else if (client.ip ~ carrier_grameenphone_bangladesh) { + set req.http.X-DfltLang = "bn"; if (req.http.X-Subdomain == "ZERO") { if (req.http.host ~ "(^(bn)\.zero|^zero)\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "Grameenphone Bangladesh"; @@ -376,6 +411,7 @@ set req.http.X-CS = "652-02"; } } else if (client.ip ~ carrier_orange_cameroon) { + set req.http.X-DfltLang = "fr"; if (req.http.X-Subdomain == "M") { if (req.http.host ~ "(^(fr|en|es|de|zh|ar|ha|ln|yo|eo)\.m|^m)\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "Orange Cameroon"; @@ -383,11 +419,13 @@ } } } else if (client.ip ~ carrier_orange_congo) { + set req.http.X-DfltLang = "fr"; if (req.http.X-Subdomain == "M") { set req.http.X-Carrier = "Orange Congo"; set req.http.X-CS = "630-86"; } } else if (client.ip ~ carrier_orange_ivory_coast) { + set req.http.X-DfltLang = "fr"; if (req.http.X-Subdomain == "M") { set req.http.X-Carrier = "Orange Ivory Coast"; set req.http.X-CS = "612-03"; @@ -397,12 +435,22 @@ set req.http.X-Carrier = "Orange Kenya"; set req.http.X-CS = "639-07"; } + } else if (client.ip ~ carrier_orange_meditel_morocco) { + set req.http.X-DfltLang = "fr"; + if (req.http.X-Subdomain == "M") { + if (req.http.host ~ "(^(fr|ar|en|es|de|it|nl|pt|ru|zh)\.m|^m)\.([a-zA-Z0-9-]+)\.org") { + set req.http.X-Carrier = "Orange Meditel Morocco"; + set req.http.X-CS = "604-00"; + } + } } else if (client.ip ~ carrier_orange_niger) { + set req.http.X-DfltLang = "fr"; if (req.http.X-Subdomain == "M") { set req.http.X-Carrier = "Orange Niger"; set req.http.X-CS = "614-04"; } } else if (client.ip ~ carrier_orange_tunisia) { + set req.http.X-DfltLang = "fr"; if (req.http.X-Subdomain == "M") { if (req.http.host ~ "(^(ar|en|fr|es|de|it|ru|ja|zh)\.m|^m)\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "Orange Tunisia"; @@ -417,6 +465,7 @@ } } } else if (client.ip ~ carrier_saudi_telecom) { + set req.http.X-DfltLang = "ar"; if (req.http.host ~ "(^(ar|bn|en|tl|ur)\.(zero|m)|^(zero|m))\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "Saudi Telecom"; set req.http.X-CS = "420-01"; @@ -431,11 +480,18 @@ set req.http.X-Carrier = "Telenor Montenegro"; set req.http.X-CS = "297-01"; } else if (client.ip ~ carrier_vimpelcom_beeline) { + set req.http.X-DfltLang = "ru"; if (req.http.host ~ "(^(en|ru)\.(zero|m)|^(zero|m))\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "Vimpelcom Beeline"; set req.http.X-CS = "250-99"; } + } else if (client.ip ~ carrier_vimpelcom_mobilink_pakistan) { + if (req.http.host ~ "(^(en)\.(zero|m)|^(zero|m))\.([a-zA-Z0-9-]+)\.org") { + set req.http.X-Carrier = "Vimpelcom Mobilink Pakistan"; + set req.http.X-CS = "410-01"; + } } else if (client.ip ~ carrier_xl_indonesia) { + set req.http.X-DfltLang = "id"; if (req.http.X-Subdomain == "ZERO") { if (req.http.host ~ "(^(id|en|zh|ar|hi|ms|jv|su)\.zero|^zero)\.([a-zA-Z0-9-]+)\.org") { set req.http.X-Carrier = "XL Axiata"; @@ -572,6 +628,13 @@ set req.http.X-ORIG-CLIENT-IP = req.http.rlnclientipaddr; } + /* This call will always set the following req.http values: + X-Subdomain = M or ZERO + X-DfltLang = en|fr|ru|... + These values are only set if the carrier has been successfully detected + X-Carrier = "Celcom Malaysia" + X-CS = "502-13" + */ call tag_carrier; /* Assemble X-Analytics header */ @@ -625,57 +688,24 @@ unset req.http.Cookie; } - if ( req.http.host == "m.wikipedia.org" ) { - if ( req.http.X-Carrier == "Orange Congo" ) { - error 666 "http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Botswana" ) { - error 666 "http://en.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Ivory Coast" ) { - error 666 "http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Niger" ) { - error 666 "http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "wikimedia" ) { - error 666 "http://en.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Uganda" ) { - error 666 "http://en.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Tunisia" ) { - error 666 "http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Kenya" ) { - error 666 "http://en.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Orange Cameroon" ) { - error 666 "http://fr.m.wikipedia.org/wiki/Sp%C3%A9cial:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Telenor Montenegro" ) { - error 666 "http://en.m.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Grameenphone Bangladesh" ) { - error 666 "http://bn.zero.wikipedia.org"; - } else if ( req.http.X-Carrier == "Saudi Telecom" ) { - error 666 "http://ar.m.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Vimpelcom Beeline" ) { - error 666 "http://ru.m.wikipedia.org/wiki/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:ZeroRatedMobileAccess"; + if (req.http.host == "m.wikipedia.org") { + if (req.http.X-Carrier) { + // Carrier detected + error 666 "http://" + req.http.X-DfltLang + ".m.wikipedia.org" + req.http.X-DfltPage; } else { + // Regular m.* request, unknown carrier, navigate to english page with the same URL error 666 "http://en.m.wikipedia.org" + req.url; } - } else if ( req.http.host == "mobile.wikipedia.org" ) { + } else if (req.http.host == "zero.wikipedia.org") { + // All ZERO requests should go to the Special:ZeroRatedMobileAccess, even for unknown carrier + error 666 "http://" + req.http.X-DfltLang + ".zero.wikipedia.org" + req.http.X-DfltPage; + } else if (req.http.host == "mobile.wikipedia.org") { error 666 "http://en.mobile.wikipedia.org" + req.url; - } else if ( req.http.host == "zero.wikipedia.org" ) { - if ( req.http.X-Carrier == "Hello Cambodia" ) { - error 666 "http://en.zero.wikipedia.org"; - } else if ( req.http.X-Carrier == "Celcom Malaysia" ) { - error 666 "http://en.zero.wikipedia.org"; - } else if ( req.http.X-Carrier == "Grameenphone Bangladesh" ) { - error 666 "http://bn.zero.wikipedia.org"; - } else if ( req.http.X-Carrier == "Saudi Telecom" ) { - error 666 "http://ar.zero.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "TATA" ) { - error 666 "http://en.zero.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if( req.http.X-Carrier == "DTAC" ) { - error 666 "http://th.zero.wikipedia.org/wiki/%E0%B8%9E%E0%B8%B4%E0%B9%80%E0%B8%A8%E0%B8%A9:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Dialog Sri Lanka" ) { - error 666 "http://en.zero.wikipedia.org/wiki/Special:ZeroRatedMobileAccess"; - } else if ( req.http.X-Carrier == "Vimpelcom Beeline" ) { - error 666 "http://ru.zero.wikipedia.org/wiki/%D0%A1%D0%BB%D1%83%D0%B6%D0%B5%D0%B1%D0%BD%D0%B0%D1%8F:ZeroRatedMobileAccess"; - } } + + // Don't need to redirect, unset default language + unset req.http.X-DfltLang; + unset req.http.X-DfltPage; if ( req.url == "/" ) { set req.url = "/?useformat=mobile"; @@ -710,6 +740,11 @@ } sub vcl_error { + // At this point we no longer need the default language. + // Hope it doesn't barf if the header is not set. + unset req.http.X-DfltLang; + unset req.http.X-DfltPage; + /* Support mobile redirects */ if (obj.status == 666) { set obj.http.Location = obj.response; -- To view, visit https://gerrit.wikimedia.org/r/57063 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I8fb36d26d437ad21f240820d8a949543fc6577e6 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Yurik <yu...@wikimedia.org> Gerrit-Reviewer: Dr0ptp4kt <ab...@wikimedia.org> Gerrit-Reviewer: Mark Bergsma <m...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits