3

Need some help in writing a rule to block the following request

The url in question is:

www.somesite.com/catalogsearch/result/?q=downloader

I have tried the following, but this does not work

location ^~ catalogsearch/result/?q=downloader {
    deny all;
}

I "think" the because the ? question mark is included is treating the url as a query string??

Regards

user1517598
  • 111
  • 1
  • 4
  • 11

1 Answers1

7

If you want to block access through the parameter q=downloader only at URL www.somesite.com/catalogsearch/result/ :

error_page 418 = @blockAccess;

location /catalogsearch/result {
        if ($args ~* "q=downloader") {
                return 418;
        }
}

location @blockAccess {
        deny all;
}

Add before location /

If you want to block the q=downloader parameter of all URL's, just put the code below before location:

error_page 418 = @blockAccess;

if ($args ~* "q=downloader") {
    return 418;
}

location @blockAccess {
    deny all;
}

If you want to block the www.somesite.com/catalogsearch/result/ :

error_page 418 = @blockAccess;

# Add before "location /"
location /catalogsearch/result {
        return 418;
}

location @blockAccess {
        deny all;
}
Valdeir Psr
  • 702
  • 1
  • 7
  • 10