Welcome! Log In Create A New Profile

Advanced

Invalid Option with Map Expression

Posted by SAH62 
Invalid Option with Map Expression
April 28, 2014 08:40AM
I have the following directive in my nginx.conf file:

map $http_user_agent $is_bot {
default 0;
~*(crawl|Google|Slurp|bingbot|tracker|click|parser|msnbot|msnbot|Gigabot|spider) 1;
}

This works just fine on a server running PHP 5.3 and nginx 1.1.19. It's causing an invalid option error when I try to start nginx on a different server running PHP 5.5 and nginx 1.4.6:

nginx: invalid option: "~*(crawl|Google|Slurp|bingbot|tracker|click|parser|msnbot|msnbot|Gigabot|spider)"

If I remove "|spider" the problem goes away. What could be wrong with this expression when it includes "spider"?
Re: Invalid Option with Map Expression
April 28, 2014 11:38AM
A little more testing has identified "spid" as the issue, not "spider", but I have no idea why that would create a regular expression problem. Clues, please?
Re: Invalid Option with Map Expression
April 28, 2014 11:48AM
Sounds like a bug, report it here http://trac.nginx.org/nginx/report/1?sort=ticket&asc=0&page=1
Re: Invalid Option with Map Expression
April 28, 2014 04:41PM
Done! Thanks for the suggestion.

http://trac.nginx.org/nginx/ticket/551
Re: Invalid Option with Map Expression
April 28, 2014 06:38PM
The ticket was closed as invalid with this comment:

"This doesn't looks like a problem in nginx. Rather, it's an incorrect assumption in init.d script you use - looks like it tries to grep nginx.conf for the "pid" directive, and fails to do it properly. Ask your package maintainer for a refund."

Indeed, /etc/init.d/nginx does this:

PID=$(awk -F'[ \t;]+' '/[^#]pid/ {print $2}' /etc/nginx/nginx.conf)

Which finds the (unintended) wrong line in my config file. I've implemented a work-around for now (changing the "p" in "spider" to "\160"). Now I just need to find the right place to report the bug. I'm using Ubuntu 14.04 LTS and this worked fine with 12.04 LTS. The nginx script has definitely changed from 12.04 to 14.04.
Re: Invalid Option with Map Expression
May 09, 2014 08:46AM
Bug reported and confirmed:

https://bugs.launchpad.net/ubuntu/+source/nginx/+bug/1314740
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 282
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready