Mark Bergsma has submitted this change and it was merged.

Change subject: Append the Varnish default internal vcl_recv
......................................................................


Append the Varnish default internal vcl_recv

It turns out that the mobile caches have been using (and relying)
on the default vcl_recv function that's appended by Varnish.
XFF handling is done there, and caching is killed for any and all
requests containing a Cookie header...

Appending it explicitly for visibility, and to allow removing it
one bit at a time.

Change-Id: I24287cb3bb4f1d88e6c4db6e99713984b35fe0a9
---
M templates/varnish/mobile-backend.inc.vcl.erb
M templates/varnish/mobile-frontend.inc.vcl.erb
2 files changed, 58 insertions(+), 0 deletions(-)

Approvals:
  Mark Bergsma: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/templates/varnish/mobile-backend.inc.vcl.erb 
b/templates/varnish/mobile-backend.inc.vcl.erb
index 0758db1..5a95113 100644
--- a/templates/varnish/mobile-backend.inc.vcl.erb
+++ b/templates/varnish/mobile-backend.inc.vcl.erb
@@ -17,6 +17,35 @@
                set req.backend = api;
        }
 <% end -%>
+
+       /* Default Varnish vcl_recv function */
+       if (req.restarts == 0) {
+               if (req.http.x-forwarded-for) {
+                       set req.http.X-Forwarded-For =
+                       req.http.X-Forwarded-For + ", " + client.ip;
+               } else {
+                       set req.http.X-Forwarded-For = client.ip;
+               }
+       }
+       if (req.request != "GET" &&
+               req.request != "HEAD" &&
+               req.request != "PUT" &&
+               req.request != "POST" &&
+               req.request != "TRACE" &&
+               req.request != "OPTIONS" &&
+               req.request != "DELETE") {
+               /* Non-RFC2616 or CONNECT which is weird. */
+               return (pipe);
+       }
+       if (req.request != "GET" && req.request != "HEAD") {
+               /* We only deal with GET and HEAD by default */
+               return (pass);
+       }
+       if (req.http.Authorization || req.http.Cookie) {
+               /* Not cacheable by default */
+               return (pass);
+       }
+       return (lookup);
 }
 
 sub vcl_fetch {
diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb 
b/templates/varnish/mobile-frontend.inc.vcl.erb
index a64e7f8..8c81ce7 100644
--- a/templates/varnish/mobile-frontend.inc.vcl.erb
+++ b/templates/varnish/mobile-frontend.inc.vcl.erb
@@ -86,6 +86,35 @@
        }
 
        set req.hash_ignore_busy = true;
+
+       /* Default Varnish vcl_recv function */
+       if (req.restarts == 0) {
+               if (req.http.x-forwarded-for) {
+                       set req.http.X-Forwarded-For =
+                       req.http.X-Forwarded-For + ", " + client.ip;
+               } else {
+                       set req.http.X-Forwarded-For = client.ip;
+               }
+       }
+       if (req.request != "GET" &&
+               req.request != "HEAD" &&
+               req.request != "PUT" &&
+               req.request != "POST" &&
+               req.request != "TRACE" &&
+               req.request != "OPTIONS" &&
+               req.request != "DELETE") {
+               /* Non-RFC2616 or CONNECT which is weird. */
+               return (pipe);
+       }
+       if (req.request != "GET" && req.request != "HEAD") {
+               /* We only deal with GET and HEAD by default */
+               return (pass);
+       }
+       if (req.http.Authorization || req.http.Cookie) {
+               /* Not cacheable by default */
+               return (pass);
+       }
+       return (lookup);
 }
 
 sub vcl_fetch {

-- 
To view, visit https://gerrit.wikimedia.org/r/75303
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I24287cb3bb4f1d88e6c4db6e99713984b35fe0a9
Gerrit-PatchSet: 1
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

Reply via email to