Skip to content

Commit 230255a

Browse files
authored
Merge pull request #107 from ruby/mitigate-cgit-crawler-overload
Reduce cgit crawler load from abbreviated-SHA requests
2 parents 77967dc + e9c72ec commit 230255a

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
repos/*
22
/test/wc.orig/
33
/test/repos.orig/
4+
/tmp/

recipes/files/etc/apache2/sites-available/git.ruby-lang.org.conf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,21 @@
2525

2626
TimeOut 300
2727

28-
# Alias /robots.txt "/var/www/git.ruby-lang.org/robots.txt"
2928
DocumentRoot /var/www/git.ruby-lang.org
3029

3130
RewriteEngine On
32-
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{40})
31+
32+
# Serve robots.txt as a static file. cgit's "ScriptAlias /" would
33+
# otherwise route it to cgit.cgi (returning 404), so crawlers never
34+
# see the Disallow rule. mod_rewrite runs before mod_alias, so this
35+
# bypasses the ScriptAlias.
36+
RewriteRule ^/robots\.txt$ /var/www/git.ruby-lang.org/robots.txt [L]
37+
38+
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{7,40})
3339
RewriteRule ^/ruby\.git/(?:log|commit|diff|patch)(?:/.*)?$ https://github.com/ruby/ruby/commit/%1 [R=302,L,NE,QSD]
34-
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{40})
40+
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{7,40})
3541
RewriteRule ^/ruby\.git/tree/(.*)$ https://github.com/ruby/ruby/tree/%1/$1 [R=302,L,NE,QSD]
36-
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{40})
42+
RewriteCond %{QUERY_STRING} (?:^|&)id=([0-9a-fA-F]{7,40})
3743
RewriteRule ^/ruby\.git/plain/(.*)$ https://github.com/ruby/ruby/raw/%1/$1 [R=302,L,NE,QSD]
3844
RewriteRule ^/ruby\.git/plain/(.*)$ https://github.com/ruby/ruby/raw/master/$1 [R=302,L,NE,QSD]
3945
</VirtualHost>

0 commit comments

Comments
 (0)