Giuseppe Lavagetto has submitted this change and it was merged. 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). Bug #70557 Change-Id: If333663b23e50b37c09412ab55d28704b018e58c Signed-off-by: Giuseppe Lavagetto <[email protected]> --- M templates/varnish/bits.inc.vcl.erb 1 file changed, 24 insertions(+), 13 deletions(-) Approvals: Giuseppe Lavagetto: Looks good to me, approved BBlack: Looks good to me, but someone else must approve jenkins-bot: Verified diff --git a/templates/varnish/bits.inc.vcl.erb b/templates/varnish/bits.inc.vcl.erb index 026c755..61998ee 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") { @@ -69,20 +87,13 @@ <% 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; - } + call mangle_request; +} <% end -%> - } + +<% if vcl_config.fetch("cluster_tier", "1") == "1" -%> +sub vcl_pass { + call mangle_request; } <% end -%> -- To view, visit https://gerrit.wikimedia.org/r/159080 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: If333663b23e50b37c09412ab55d28704b018e58c Gerrit-PatchSet: 4 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Giuseppe Lavagetto <[email protected]> Gerrit-Reviewer: BBlack <[email protected]> Gerrit-Reviewer: Giuseppe Lavagetto <[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
