From e405261321e1d611d2d1b7a32adba3f84d22b7e7 Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Fri, 16 May 2025 05:11:38 +0100 Subject: [PATCH] gitweb: fix robots.txt in attempt to limit abuse --- cookbooks/git/templates/default/apache.erb | 8 ++++++++ cookbooks/git/templates/default/robots.txt.erb | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cookbooks/git/templates/default/apache.erb b/cookbooks/git/templates/default/apache.erb index daff9de88..c7ee8d1d6 100644 --- a/cookbooks/git/templates/default/apache.erb +++ b/cookbooks/git/templates/default/apache.erb @@ -44,6 +44,14 @@ CustomLog /var/log/apache2/<%= @name %>-access.log combined_extended ErrorLog /var/log/apache2/<%= @name %>-error.log + Alias /robots.txt /srv//srv/<%= node[:git][:host] %>/robots.txt + + + # Make absolutely sure it comes out as a plain file + SetHandler none + Require all granted + + SetEnv GIT_PROJECT_ROOT /var/lib/git SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_HTTP_MAX_REQUEST_BUFFER 100M diff --git a/cookbooks/git/templates/default/robots.txt.erb b/cookbooks/git/templates/default/robots.txt.erb index b60d5e279..385fe1645 100644 --- a/cookbooks/git/templates/default/robots.txt.erb +++ b/cookbooks/git/templates/default/robots.txt.erb @@ -1,4 +1,13 @@ # DO NOT EDIT - This file is being maintained by Chef User-agent: * -Disallow: /*/snapshot/ +Disallow: /*a=search* +Disallow: /*/search/* +Disallow: /*a=blobdiff* +Disallow: /*/blobdiff/* +Disallow: /*a=commitdiff* +Disallow: /*/commitdiff/* +Disallow: /*a=snapshot* +Disallow: /*/snapshot/* +Disallow: /*a=blame* +Disallow: /*/blame/* -- 2.39.5