Should it be "if ( $request_method !~ ^(GET...)" or "limit_except GET..." ?

Mark Alan m6rkalan at gmail.com
Wed Jan 23 11:56:32 UTC 2013


Hello,


Can anybody tell me if the bellow constructs are equivalent?

In case of a dozen or so 'location', would it still be better to have a
limit_except for each location or, in that case, would it be better to
have a server level single 'if ( $request_method...' ?

server {
  ...
  if ( $request_method !~ ^(?:GET|HEAD|POST)$ ) { return 444; }
  ...

server {
  ...
  location / {
    limit_except GET HEAD POST { deny  all; }
  ...

Thank you,
Mark



More information about the nginx mailing list