Giuseppe Lavagetto has uploaded a new change for review.

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

Change subject: varnish: mangle request data for uncacheable objects
......................................................................

varnish: mangle request data for uncacheable objects

Uncacheable objects in bits now receive an hit_for_pass response from
vcl_fetch; so we need to mangle the request url there or subsequent
requests will be sent un-rewritten to the backend, resulting in a 404
which will be cached for a long time. This only affected urls with
debug=true (not cached).

Change-Id: If333663b23e50b37c09412ab55d28704b018e58c
Signed-off-by: Giuseppe Lavagetto <[email protected]>
---
M templates/varnish/bits.inc.vcl.erb
1 file changed, 22 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/80/159080/1

diff --git a/templates/varnish/bits.inc.vcl.erb 
b/templates/varnish/bits.inc.vcl.erb
index 026c755..d8cff08 100644
--- a/templates/varnish/bits.inc.vcl.erb
+++ b/templates/varnish/bits.inc.vcl.erb
@@ -3,6 +3,24 @@
 include "errorpage.inc.vcl";
 include "hhvm.inc.vcl";
 
+sub mangle_request {
+       /* transform backend url: /<sitename>/load.php -> /w/load.php
+          set host header for backend to <sitename>
+       */
+       if ( req.url ~ 
"^/([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+)\.<%= Regexp.escape( 
cluster_options.fetch( "top_domain", "org" ) ) %>/load\.php" ) {
+               set bereq.http.host = regsub( req.url, "^/([^/]+)/(.*)$", "\1" 
);
+               set bereq.url = regsub( req.url, "^/([^/]+)/load\.php(.*)?", 
"/w/load.php\2" );
+<% if cluster_options.fetch( "test_hostname", false ) -%>
+
+               # Send test.wikipedia.org to the right backend server
+               if ( req.url ~ "^/<%= Regexp.escape( cluster_options.fetch( 
"test_hostname" ) ) %>/load\.php" ) {
+                       set req.backend = test_wikipedia;
+               }
+<% end -%>
+       }
+}
+
+
 sub vcl_recv {
        /* Since we are allowing POST at wikimedia3.vcl.erb, disallow here */
        if (req.request == "POST") {
@@ -58,6 +76,9 @@
 <% end -%>
        if (beresp.ttl <= 0s) {
                set beresp.ttl = 120s;
+<% if vcl_config.fetch("cluster_tier", "1") == "1" -%>
+               call mangle_request;
+<% end -%>
                return (hit_for_pass);
        }
 
@@ -69,20 +90,7 @@
 
 <% if vcl_config.fetch("cluster_tier", "1") == "1" -%>
 sub vcl_miss {
-       /* transform backend url: /<sitename>/load.php -> /w/load.php
-          set host header for backend to <sitename>
-       */
-       if ( req.url ~ 
"^/([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+\.)?([a-zA-Z0-9-]+)\.<%= Regexp.escape( 
cluster_options.fetch( "top_domain", "org" ) ) %>/load\.php" ) {
-               set bereq.http.host = regsub( req.url, "^/([^/]+)/(.*)$", "\1" 
);
-               set bereq.url = regsub( req.url, "^/([^/]+)/load\.php(.*)?", 
"/w/load.php\2" );
-<% if cluster_options.fetch( "test_hostname", false ) -%>
-
-               # Send test.wikipedia.org to the right backend server
-               if ( req.url ~ "^/<%= Regexp.escape( cluster_options.fetch( 
"test_hostname" ) ) %>/load\.php" ) {
-                       set req.backend = test_wikipedia;
-               }
-<% end -%>
-       }
+       call mangle_request;
 }
 <% end -%>
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If333663b23e50b37c09412ab55d28704b018e58c
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Giuseppe Lavagetto <[email protected]>

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

Reply via email to