]> git.openstreetmap.org Git - chef.git/commitdiff
Charge map export requests at a high rate than normal tiles
authorTom Hughes <tom@compton.nu>
Wed, 28 Jul 2021 18:27:22 +0000 (19:27 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 28 Jul 2021 18:27:22 +0000 (19:27 +0100)
cookbooks/tile/templates/default/tile-ratelimit.erb

index f0483b4d712863f8e69c63ed80f67cd22d142247..63e7711b3cd26df70a68001aefb41d6441f2df62 100755 (executable)
@@ -50,6 +50,7 @@ File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line|
     hash = parser.parse!(line)
 
     address = hash["%a"]
+    request = hash["%r"]
 
     next if address == "127.0.0.1" || address == "::1"
 
@@ -61,7 +62,11 @@ File::Tail::Logfile.tail("/var/log/apache2/access.log") do |line|
 
     decay_count(client, time)
 
-    client[:request_count] = client[:request_count] + 1
+    if request =~ %r{^(GET|POST) /cgi-bin/export.*}
+      client[:request_count] = client[:request_count] + 150
+    else
+      client[:request_count] = client[:request_count] + 1
+    end
 
     if client[:request_count] > BLOCK_AT && !client.has_key?(:blocked_at)
       puts "Blocked #{address}"