Pcre_compile() failed: unrecognized character after (?<

server {
server_name ~^test.(?.+)$;

location / {
    root  /sites/$domain;
}

}

nginx -t

[emerg]: pcre_compile() failed: unrecognized character after (?< in
“^test.(?.+)$” at “domain>.+)$” in
/etc/nginx/vhosts/testdomain:11
configuration file /etc/nginx/nginx.conf test failed

nginx -V

nginx version: nginx/0.8.29
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
TLS SNI support disabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx
–conf-path=/etc/nginx/nginx.conf
–error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid
–with-rtsig_module --with-select_module --with-poll_module
–with-http_ssl_module --with-http_stub_status_module
–with-http_gzip_static_module --with-http_dav_module
–with-http_flv_module --with-http_xslt_module
–with-http_random_index_module --with-http_image_filter_module
–http-log-path=/var/log/nginx/access.log --with-md5=/usr/lib
–with-sha1=/usr/lib --with-http_perl_module

Can’t tell what I’m doing wrong. Advice please?

IMHO, this is a pcre version issue. Old versions do not support named
selections.

Could you please try to update your system pcre library or just
compile the latest lib version in nginx using --with-pcre=/path/to/
custom/pcre

On Fri, Dec 11, 2009 at 01:10:33PM +0000, Phillip O. wrote:

configuration file /etc/nginx/nginx.conf test failed

nginx -V

nginx version: nginx/0.8.29
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-44)
TLS SNI support disabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --with-rtsig_module --with-select_module --with-poll_module --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_dav_module --with-http_flv_module --with-http_xslt_module --with-http_random_index_module --with-http_image_filter_module --http-log-path=/var/log/nginx/access.log --with-md5=/usr/lib --with-sha1=/usr/lib --with-http_perl_module

Can’t tell what I’m doing wrong. Advice please?

It seems you have PCRE prior to 7.0, try:

  • server_name   ~^test\.(?<domain>.+)$;
    
  • server_name   ~^test\.(?P<domain>.+)$;
    


Igor S.
http://sysoev.ru/en/

Igor S. wrote:

It seems you have PCRE prior to 7.0, try:

  • server_name   ~^test\.(?<domain>.+)$;
    
  • server_name   ~^test\.(?P<domain>.+)$
    

I have pcre-6.6 available on the machine.

I can confirm that’s working, and I’ve updated the wiki with this
information.

Thanks Igor!

On Fri, Dec 11, 2009 at 04:40:05PM +0300, Peter L. wrote:

IMHO, this is a pcre version issue. Old versions do not support named
selections.

Could you please try to update your system pcre library or just
compile the latest lib version in nginx using --with-pcre=/path/to/
custom/pcre

The alternatvie syntax “?P<…>” can be used. It’s old enough.

nginx -t

error.log --pid-path=/var/run/nginx.pid --with-rtsig_module --with-
select_module --with-poll_module --with-http_ssl_module --with-
http_stub_status_module --with-http_gzip_static_module --with-
http_dav_module --with-http_flv_module --with-http_xslt_module –
with-http_random_index_module --with-http_image_filter_module --http-
log-path=/var/log/nginx/access.log --with-md5=/usr/lib --with-sha1=/
usr/lib --with-http_perl_module

Can’t tell what I’m doing wrong. Advice please?


Igor S.
http://sysoev.ru/en/