I'm using nginx-1.6.2,2
and I'd like return error 410
for URL that matches /browse.php?u=http
, so requests such as this will get 410:
162.218.208.16 - - [21/Nov/2014:12:35:40 -0500] "GET /browse.php?u=http%3A%2F%2Fwww.bing.com%2Fsearch%3Fq%3DBroke%2C%2BUSA%2Bfiletype%3Apdf%26first%3D0%26count%3D20%26format%3Drss&b=156&f=norefer HTTP/1.1" 403 570 "http://ww.thespacesurf.com/browse.php?u=http%3A%2F%2Fwww.bing.com%2Fsearch%3Fq%3DBroke%2C%2BUSA%2Bfiletype%3Apdf%26first%3D0%26count%3D20%26format%3Drss&b=156&f=norefer" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)"
I don't really need regex
, so something like this, but it's not working:
location = /browse.php?u=http {
return 410;
}
couple of days later, I grep -c
for 410
in /var/log/nginx-access.log
$ bzip2 -cd /var/log/nginx-access.log.0.bz2 | grep -c ' 410 '
5665
$
and that made me feel warm and fuzzy) thanks again!
You can't match the query string in the declaration of a location statement so you need something like this :
That's because location is
/browse.php
, not the one you specified.There are several ways to do it. For example, something like this should do:
P.S.: or use
~*
instead of~
ifu=http
is case-insensitive.