Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Block weird requests coming from stupid spiders


set $stupid_spider "";

# If the request comes from one of these stupid spiders
if ($http_user_agent ~* (stupid|spider)) {
    set $stupid_spider "1";

# And if it contains these weird characters
if ($uri ~ (\(|\)|\;|:|\+)) {
    set $stupid_spider "${stupid_spider}1";

# Then we block it here
if ($stupid_spider = "11") {
    return 404;


<LocationMatch "(\(|\)|\;|:|\+)">
    SetEnvIfNoCase User-Agent "(stupid|spiders|-?)" GoAway=1
    Deny from env=GoAway
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.