Should we use "if ( $request_method ..." or "limit_except ..." ?

Mark Alan varia at e-healthexpert.org
Fri Sep 28 11:04:20 UTC 2012


Hello list,


Can anybody tell me if the bellow constructs are equivalent?

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

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

And, if they are equivalent, in the case of having multiple locations,
is it still better to have a limit_except for each location? Or, in
this case is it better to have a single "if ( $request_method ..."  at
server level ?

Thank you,
Mark



More information about the nginx mailing list