unknown directive "if" in /usr/local/nginx/nginx.conf

johndesp nginx-forum at nginx.us
Tue Nov 24 21:14:28 MSK 2009


Thanks.  My ultimate goal is to have the flexibility to inspect the incoming uri and make decisions as to what backend host to send the request to.

For instance,

I might want

Incoming URI  /johndesp/( {1})  ----> proxy_pass  http://host1/johndesp/whatever

Incoming URI  /johndesp/([0-9] {1})  ----> proxy_pass  http://host1/johndesp/whenever


/johndesp/b    ---------------- proxy_pass  http://host1:8080/johndesp/whatever             * notice this is not  http://host1:8080/johndesp/whatever/b

likewise I would want the following:

johndesp/5    ---------------- proxy_pass  http://host2:8080/johndesp/whenever           * notice this is not  http://host1:8080/johndesp/whatever

I tried to use the following..however, I did not get the desired result:

location "~* ^/johndesp/whatever/( {1}"{
proxy_pass http://host1:8080/johndesp/whatever;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;

but I get this error:
: the using of the regex " ^/johndesp/whatever/( {1}" requires PCRE library in /usr/local/nginx/nginx.conf:43

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,25320,25356#msg-25356

More information about the nginx mailing list