Trying to block google scripts with apache

Viewed 303

Someone is doing requests to my server with Google Scripts and i don't know how to block it. This is a part of my apache access.log:

107.178.224.172 - - [26/Aug/2020:09:27:49 +0000] "GET / HTTP/1.1" 404 4136 "-" "Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: UAEmdDd_ShAsltnvAuXhIA9JjNYyHv4J10nc)"
107.178.195.11 - - [26/Aug/2020:09:04:46 +0000] "GET / HTTP/1.1" 200 4795 "-" "Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: UAEmdDd_ShAsltnvAuXhIA9JjNYyHv4J10nc)"
35.187.134.84 - - [26/Aug/2020:09:32:47 +0000] "GET / HTTP/1.1" 404 4120 "-" "Mozilla/5.0 (compatible; Google-Apps-Script; beanserver; +https://script.google.com; id: UAEmdDd_ShAsltnvAuXhIA9JjNYyHv4J10nc)"

As you can see it is doing requests with different IPs, and that's slowing down my server. How can i block it?

1 Answers

In your webserver .htaccess file:

RewriteCond %{HTTP_USER_AGENT} ^.*beanserver.*$ [NC]
RewriteRule .* - [R=403,L,E=WHY:Bad_UA]

This will test for any user agent which contains "beanserver" and reject the request with a 403 error.

Additionally, it will set the environment variable "WHY" to the value "Bad_UA", which can be used if necessary in your 403.php script.

Related