Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Looking to block any requests that contain the following strings in nginx

'%0d','%0a','%0D','%0A'

Just really looking to return like a 500 error or such.. Nothing fancy

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I think a server-level if is what you need. If you want to search the whole request, including args, you should be able to use:

server {
  if ($request_uri ~ %0[adAD]) { return 500; }
}

If you just want to check the path part of the uri:

server {
  if ($uri ~ [\r\n]) { return 500; }
}

should do the job

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.