20

A client wants me to block access to a page unless the http_user_agent = xxx.

Is there a way to do this? I was thinking of an if else or if not function but this doesn't seem to exist.

If I wanted to block a user agent I could do the below but is there a way to only allow that user agent?

if ($http_user_agent ~* (xxx) ) {
   return 403; 
}
Pravitha V
  • 3,308
  • 4
  • 33
  • 51
Phil
  • 201
  • 1
  • 2
  • 3

1 Answers1

28

Use the !~* operator which is the negated version of ~*.

See this document for details.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81