If you want to use regexes (to negate) you should use it properly, e.g. start with a "~". See more: http://nginx.org/en/docs/http/ngx_http_map_module.html That said, Francis' idea is a good one. Trying to negate things in regex is quite counterproductive. Posted at Nginx Forum: https://forum.nginx.org/read.php?2,295157,295161#msg-295161