Mark Bergsma has uploaded a new change for review.

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


Change subject: Serve a /robots.txt if the backend doesn't
......................................................................

Serve a /robots.txt if the backend doesn't

Change-Id: If72938c111061975bf8597ffabd5ca07d2836858
---
M templates/varnish/misc.inc.vcl.erb
1 file changed, 19 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/74/79574/1

diff --git a/templates/varnish/misc.inc.vcl.erb 
b/templates/varnish/misc.inc.vcl.erb
index 1bca91c..3fd2cf0 100644
--- a/templates/varnish/misc.inc.vcl.erb
+++ b/templates/varnish/misc.inc.vcl.erb
@@ -1,5 +1,14 @@
 include "errorpage.inc.vcl";
 
+call robots_txt_disallow_all {
+       set obj.status = 200;
+       set obj.http.Connection = "keep-alive";
+       synthetic {"
+User-agent: *
+Disallow: /
+       "}
+}
+
 sub vcl_recv {
        if (req.http.Host == "git.wikimedia.org") {
                set req.backend = antimony;
@@ -13,7 +22,17 @@
        }
 }
 
+sub vcl_fetch {
+       if (req.url == "/robots.txt" && (beresp.status != 200 || 
beresp.http.Content-Length == "0")) {
+               error 667 "OK";
+       }
+}
+
 sub vcl_error {
+       if (obj.status == 667) {
+               call robots_txt_disallow_all;
+               return(deliver);
+       }
        call errorpage;
        return(deliver);
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If72938c111061975bf8597ffabd5ca07d2836858
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