Skip to content

Instantly share code, notes, and snippets.

@felipekm
Created February 28, 2025 13:57
Show Gist options
  • Save felipekm/134df87d321b8a4f39c623f3ab0f646a to your computer and use it in GitHub Desktop.
Save felipekm/134df87d321b8a4f39c623f3ab0f646a to your computer and use it in GitHub Desktop.
NGINX - Block bad bots and unwanted scrapers by filtering User-Agents
server {
location /api/ {
if ($http_user_agent ~* (curl|wget|bot|crawler)) {
return 403; # Block known scrapers and bots
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment