Mark Bergsma has submitted this change and it was merged.
Change subject: Munge and restore Cookie on both frontend and backend
......................................................................
Munge and restore Cookie on both frontend and backend
Factor this out to an include file common to front and backend
Change-Id: Ib72648d2def4e4fb18e8ea9b4dbdd7bee676ae09
---
M manifests/role/cache.pp
M templates/varnish/text-backend.inc.vcl.erb
A templates/varnish/text-common.inc.vcl.erb
M templates/varnish/text-frontend.inc.vcl.erb
4 files changed, 28 insertions(+), 15 deletions(-)
Approvals:
Mark Bergsma: Looks good to me, approved
jenkins-bot: Verified
diff --git a/manifests/role/cache.pp b/manifests/role/cache.pp
index 1545a7a..ab33e52 100644
--- a/manifests/role/cache.pp
+++ b/manifests/role/cache.pp
@@ -440,6 +440,7 @@
varnish::instance { "text-backend":
name => "",
vcl => "text-backend",
+ extra_vcl => ["text-common"],
port => 3128,
admin_port => 6083,
runtime_parameters => $::site ? {
@@ -487,6 +488,7 @@
varnish::instance { "text-frontend":
name => "frontend",
vcl => "text-frontend",
+ extra_vcl => ["text-common"],
port => 80,
admin_port => 6082,
storage => "-s malloc,${memory_storage_size}G",
diff --git a/templates/varnish/text-backend.inc.vcl.erb
b/templates/varnish/text-backend.inc.vcl.erb
index 2ffd599..a6a0260 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -1,10 +1,13 @@
# Varnish VCL include file for text backends
include "errorpage.inc.vcl";
+include "text-common.inc.vcl";
sub vcl_recv {
call vcl_recv_purge;
call restrict_access;
+
+ call cookie_munging;
<% if vcl_config.fetch("cluster_tier", "1") == "1" -%>
if ( req.http.host ~ "^test\." ) {
@@ -24,11 +27,7 @@
}
sub vcl_miss {
-<% if vcl_config.fetch("cluster_tier", "1") == "1" -%>
- /* Restore the original Cookie header for MediaWiki */
- set req.http.Cookie = req.http.Orig-Cookie;
- unset req.http.Orig-Cookie;
-<% end -%>
+ call restore_cookie;
}
sub vcl_error {
diff --git a/templates/varnish/text-common.inc.vcl.erb
b/templates/varnish/text-common.inc.vcl.erb
new file mode 100644
index 0000000..0e9657f
--- /dev/null
+++ b/templates/varnish/text-common.inc.vcl.erb
@@ -0,0 +1,17 @@
+# Common functions for the Text Varnish cluster
+
+sub cookie_munging {
+ if (req.http.Cookie ~ "([sS]ession|Token)=") {
+ return(pass);
+ }
+
+ /* This header is saved, and restored before sending it to MediaWiki */
+ set req.http.Orig-Cookie = req.http.Cookie;
+ unset req.http.Cookie;
+}
+
+sub restore_cookie {
+ /* Restore the original Cookie header for upstream */
+ set req.http.Cookie = req.http.Orig-Cookie;
+ unset req.http.Orig-Cookie;
+}
diff --git a/templates/varnish/text-frontend.inc.vcl.erb
b/templates/varnish/text-frontend.inc.vcl.erb
index 5ce6162..ab06f59 100644
--- a/templates/varnish/text-frontend.inc.vcl.erb
+++ b/templates/varnish/text-frontend.inc.vcl.erb
@@ -1,6 +1,7 @@
# Varnish VCL include file for text frontends
include "errorpage.inc.vcl";
+include "text-common.inc.vcl";
sub mobile_redirect {
if ((req.http.User-Agent ~ "mobi" || req.http.Accept ~ "vnd.wap.wml")
@@ -14,16 +15,6 @@
}
unset req.http.MobileHost;
}
-}
-
-sub cookie_munging {
- if (req.http.Cookie ~ "([sS]ession|Token)=") {
- return(pass);
- }
-
- /* This header is saved, and restored before sending it to MediaWiki */
- set req.http.Orig-Cookie = req.http.Cookie;
- unset req.http.Cookie;
}
sub vcl_recv {
@@ -51,6 +42,10 @@
return(lookup);
}
+sub vcl_miss {
+ call restore_cookie;
+}
+
sub vcl_deliver {
/* Override the Cache-Control header for wiki content pages */
if (req.url ~ "(?i)^/w(iki)?/.*"
--
To view, visit https://gerrit.wikimedia.org/r/66119
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib72648d2def4e4fb18e8ea9b4dbdd7bee676ae09
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <[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