3

I am having a problem trying to get the following configuration to work. Every time I run the config test I get a failed pass. To start off let me show you a working configuration

location / { if ($query_string ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3D)"){ return 403; } }

But when I try be a little clever and place this in a map block I get a error

map $query_string $edgars_access_denied { default "200"; ~mosConfig_[a-zA-Z_]{1,21}(=|\%3D) "403"; }

WilhelmE
  • 133
  • 3

1 Answers1

7

Curly braces like semi-colons have a special meaning in nginx's configuration thus you must turn your regex into an explicit string by surrounding it with either single or double quotes.

map $query_string $edgars_access_denied {
    default "200";
   "~mosConfig_[a-zA-Z_]{1,21}(=|\%3D)" "403";
}
Xavier Lucas
  • 12,815
  • 2
  • 44
  • 50