Mark Bergsma has uploaded a new change for review. https://gerrit.wikimedia.org/r/60423
Change subject: Make purging more generic, unbreak purging on mobile cluster ...................................................................... Make purging more generic, unbreak purging on mobile cluster Change-Id: I76e5c4218c1dec06673aa5121010875031c1a1e2 --- M manifests/role/cache.pp M templates/varnish/mobile-backend.inc.vcl.erb M templates/varnish/mobile-frontend.inc.vcl.erb M templates/varnish/upload-frontend.inc.vcl.erb M templates/varnish/wikimedia.vcl.erb 5 files changed, 13 insertions(+), 33 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/23/60423/1 diff --git a/manifests/role/cache.pp b/manifests/role/cache.pp index 08c99ed..9d30778 100644 --- a/manifests/role/cache.pp +++ b/manifests/role/cache.pp @@ -473,6 +473,7 @@ vcl_config => { 'retry5xx' => 0, 'cache4xx' => "1m", + 'purge_regex' => '^http://upload\.wikimedia\.org/', 'cluster_tier' => $cluster_tier, }, backend_options => [ @@ -508,6 +509,7 @@ vcl_config => { 'retry5xx' => 0, 'cache4xx' => "1m", + 'purge_regex' => '^http://upload\.wikimedia\.org/', 'cluster_tier' => $cluster_tier, }, backend_options => [ diff --git a/templates/varnish/mobile-backend.inc.vcl.erb b/templates/varnish/mobile-backend.inc.vcl.erb index 6d4dd57..ba61fbc 100644 --- a/templates/varnish/mobile-backend.inc.vcl.erb +++ b/templates/varnish/mobile-backend.inc.vcl.erb @@ -1,12 +1,7 @@ # Varnish VCL include file for mobile backends sub vcl_recv { - if (req.http.host ~ "^([a-zA-Z0-9-]+)\.(m|zero|wap|mobile)\.") { - call vcl_recv_purge; - } - elsif (req.request == "PURGE") { - error 200 "Domain not cached here."; - } + call vcl_recv_purge; if ( req.http.host ~ "^test\." ) { set req.backend = test_wikipedia; diff --git a/templates/varnish/mobile-frontend.inc.vcl.erb b/templates/varnish/mobile-frontend.inc.vcl.erb index ea2ba3c..f6949ea 100644 --- a/templates/varnish/mobile-frontend.inc.vcl.erb +++ b/templates/varnish/mobile-frontend.inc.vcl.erb @@ -513,13 +513,6 @@ } sub vcl_recv { - if (req.http.host ~ "^([a-zA-Z0-9-]+)\.(m|zero|wap|mobile)\.") { - call vcl_recv_purge; - } - elsif (req.request == "PURGE") { - error 200 "Domain not cached here."; - } - /* if the request comes from Opera Mini's accelerating proxies, grab * XFF Header and replace client ip value */ if (client.ip ~ opera_mini) { @@ -583,6 +576,9 @@ set req.url = regsub(req.url, "\S+[\?&]go=([^&]+).*", "/wiki/\1"); } + /* Allow purging */ + call vcl_recv_purge; + /* FIXME: deploy X-Vary-Options support */ set req.http.X-Orig-Cookie = req.http.Cookie; if( req.http.Cookie ~ "disable" || diff --git a/templates/varnish/upload-frontend.inc.vcl.erb b/templates/varnish/upload-frontend.inc.vcl.erb index 5cd44d1..31103a1 100644 --- a/templates/varnish/upload-frontend.inc.vcl.erb +++ b/templates/varnish/upload-frontend.inc.vcl.erb @@ -3,19 +3,7 @@ import std; sub vcl_recv { - /* Support HTTP PURGE from localhost */ - if (req.request == "PURGE") { - if (!client.ip ~ purge) { - error 405 "Denied."; - # This is a stupid hack to make varnishhtcpd work - it's using a perl mod that sends purge reqs like - # PURGE http://de.wikipedia.orghttp://de.wikipedia.org/w/index.php - } elsif (req.url ~ "^http://upload.wikimedia.org") { - set req.url = regsub ( req.url, "^http://[\w.]+(/.*)", "\1"); - return (lookup); - } else { - error 200 "Domain not cached here."; - } - } + call vcl_recv_purge; if (req.request != "GET" && req.request != "HEAD") { /* We only deal with GET, HEAD at this point */ diff --git a/templates/varnish/wikimedia.vcl.erb b/templates/varnish/wikimedia.vcl.erb index b65e52b..11cde08 100644 --- a/templates/varnish/wikimedia.vcl.erb +++ b/templates/varnish/wikimedia.vcl.erb @@ -177,16 +177,15 @@ } sub vcl_recv_purge { - /* Support HTTP PURGE from localhost */ + /* Support HTTP PURGE */ if (req.request == "PURGE") { if (!client.ip ~ purge) { error 405 "Denied."; - # This is a stupid hack to make varnishhtcpd work - it's using a perl mod that sends purge reqs like - # PURGE http://de.wikipedia.orghttp://de.wikipedia.org/w/index.php - } elsif (req.url ~ "^http:") { - set req.url = regsub(req.url, "^http://[\w.]+(/.*)", "\1"); - } - return (lookup); + } elsif (req.url ~ "<%= vcl_config.fetch("purge_regex", "^http:") %>") { + call rewrite_proxy_urls; + return (lookup); + } else { + error 200 "Domain not cached here."; } } -- To view, visit https://gerrit.wikimedia.org/r/60423 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I76e5c4218c1dec06673aa5121010875031c1a1e2 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Mark Bergsma <m...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits