How to block Googlebot in Nginx

Sometime you want to block Googlebot to crawl your site. Googlebot user agent only have googlebot/2.1 or “Googlebot/2.1 (+http://www.googlebot.com/bot.html)”. Here are a simple snippet to block Googlebot using Nginx server. This block will redirect Googlebot and serve 403 response.

Put it in your location / directive or any location block of your root.

if ($http_user_agent ~ (googlebot) ) {   return 403;}

Leave a Reply

Your email address will not be published. Required fields are marked *