Mark Bergsma has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/66119


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, 27 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/19/66119/1

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..6ce03b6 100644
--- a/templates/varnish/text-backend.inc.vcl.erb
+++ b/templates/varnish/text-backend.inc.vcl.erb
@@ -6,6 +6,8 @@
        call vcl_recv_purge;
        call restrict_access;
 
+       call cookie_munging;
+
 <% if vcl_config.fetch("cluster_tier", "1") == "1" -%>
        if ( req.http.host ~ "^test\." ) {
                set req.backend = test_wikipedia;
@@ -24,11 +26,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: newchange
Gerrit-Change-Id: Ib72648d2def4e4fb18e8ea9b4dbdd7bee676ae09
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Mark Bergsma <[email protected]>

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

Reply via email to