error_page, try_files, internal redirect ends up in SIGSEGV

Grégory Pakosz gpakosz at yahoo.fr
Sat Apr 21 00:47:23 UTC 2012


Hello,

I'm facing a SIGSEGV when trying to setup a custom error page using
the following (shortened for the sake of debugging) configuration.

/etc/nginx/sites-available/example.com:
server {
  listen 80;
  server_name example.com;

  access_log /var/log/nginx/example.com_access.log;
  error_log /var/log/nginx/example.com_error.log debug;

  root /var/www;

  error_page 404 @404;

  location @404 {
    try_files /404.html =404;
  }

  location / {
    try_files $uri $uri/ /index.php;
  }

  location ~ \.php$ {
    try_files $uri =404;

#    include php.conf;
#    fastcgi_pass unix:/var/run/php5-fpm/www.sock;
  }
}

The intent is to test whether $uri exists as a file, then a directory,
then if it doesn't exist defer to index.php if present. When index.php
doesn't exist, use the custom 404 page.

/var/www content:
  /var/www/index.html
  /var/www/404.html

There is no /var/www/index.php and I'm expecting my custom 404.html
page to be served.

Here is a debug log when accessing http://example.com/foo.txt

2012/04/21 02:38:41 [debug] 18030#0: *71 event timer del: 35: 3528919376
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 0
2012/04/21 02:38:41 [debug] 18030#0: *71 rewrite phase: 1
2012/04/21 02:38:41 [debug] 18030#0: *71 test location: "/"
2012/04/21 02:38:41 [debug] 18030#0: *71 test location: ~ "\.php$"
2012/04/21 02:38:41 [debug] 18030#0: *71 using configuration "/"
2012/04/21 02:38:41 [debug] 18030#0: *71 http cl:-1 max:524288
2012/04/21 02:38:41 [debug] 18030#0: *71 rewrite phase: 3
2012/04/21 02:38:41 [debug] 18030#0: *71 post rewrite phase: 4
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 5
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 6
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 7
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 8
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 9
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 10
2012/04/21 02:38:41 [debug] 18030#0: *71 post access phase: 11
2012/04/21 02:38:41 [debug] 18030#0: *71 try files phase: 12
2012/04/21 02:38:41 [debug] 18030#0: *71 http script var: "/foo.txt"
2012/04/21 02:38:41 [debug] 18030#0: *71 trying to use file:
"/foo.txt" "/var/www/foo.txt"
2012/04/21 02:38:41 [debug] 18030#0: *71 add cleanup: 09D15FA8
2012/04/21 02:38:41 [debug] 18030#0: *71 malloc: 09C2E528:88
2012/04/21 02:38:41 [debug] 18030#0: *71 malloc: 09C2E5B0:55
2012/04/21 02:38:41 [debug] 18030#0: *71 cached open file:
/var/www/foo.txt, fd:-1, c:0, e:2, u:1
2012/04/21 02:38:41 [debug] 18030#0: *71 http script var: "/foo.txt"
2012/04/21 02:38:41 [debug] 18030#0: *71 trying to use dir: "/foo.txt"
"/var/www/foo.txt"
2012/04/21 02:38:41 [debug] 18030#0: *71 add cleanup: 09D15FC4
2012/04/21 02:38:41 [debug] 18030#0: *71 cached open file:
/var/www/foo.txt, fd:-1, c:0, e:2, u:2
2012/04/21 02:38:41 [debug] 18030#0: *71 trying to use file:
"/index.php" "/var/www/index.php"
2012/04/21 02:38:41 [debug] 18030#0: *71 internal redirect: "/index.php?"
2012/04/21 02:38:41 [debug] 18030#0: *71 rewrite phase: 1
2012/04/21 02:38:41 [debug] 18030#0: *71 test location: "/"
2012/04/21 02:38:41 [debug] 18030#0: *71 test location: ~ "\.php$"
2012/04/21 02:38:41 [debug] 18030#0: *71 using configuration "\.php$"
2012/04/21 02:38:41 [debug] 18030#0: *71 http cl:-1 max:524288
2012/04/21 02:38:41 [debug] 18030#0: *71 rewrite phase: 3
2012/04/21 02:38:41 [debug] 18030#0: *71 post rewrite phase: 4
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 5
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 6
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 7
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 8
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 9
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 10
2012/04/21 02:38:41 [debug] 18030#0: *71 post access phase: 11
2012/04/21 02:38:41 [debug] 18030#0: *71 try files phase: 12
2012/04/21 02:38:41 [debug] 18030#0: *71 http script var: "/index.php"
2012/04/21 02:38:41 [debug] 18030#0: *71 trying to use file:
"/index.php" "/var/www/index.php"
2012/04/21 02:38:41 [debug] 18030#0: *71 add cleanup: 09D1602C
2012/04/21 02:38:41 [debug] 18030#0: *71 malloc: 09C2E5F0:88
2012/04/21 02:38:41 [debug] 18030#0: *71 malloc: 09C2E650:57
2012/04/21 02:38:41 [debug] 18030#0: *71 cached open file:
/var/www/index.php, fd:-1, c:0, e:2, u:1
2012/04/21 02:38:41 [debug] 18030#0: *71 trying to use file: "=404"
"/var/www=404"
2012/04/21 02:38:41 [debug] 18030#0: *71 http finalize request: 404,
"/index.php?" a:1, c:2
2012/04/21 02:38:41 [debug] 18030#0: *71 http special response: 404,
"/index.php?"
2012/04/21 02:38:41 [debug] 18030#0: *71 test location: "@404"
2012/04/21 02:38:41 [debug] 18030#0: *71 using location: @404 "/index.php?"
2012/04/21 02:38:41 [debug] 18030#0: *71 rewrite phase: 3
2012/04/21 02:38:41 [debug] 18030#0: *71 post rewrite phase: 4
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 5
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 6
2012/04/21 02:38:41 [debug] 18030#0: *71 generic phase: 7
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 8
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 9
2012/04/21 02:38:41 [debug] 18030#0: *71 access phase: 10
2012/04/21 02:38:41 [debug] 18030#0: *71 post access phase: 11
2012/04/21 02:38:41 [debug] 18030#0: *71 try files phase: 12

At which point nginx crashes, /var/log/nginx/error.log:
2012/04/21 02:38:41 [alert] 17786#0: worker process 18030 exited on signal 11

# nginx -V
nginx version: nginx/1.1.19
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-log-path=/var/log/nginx/access.log
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid
--with-debug --with-http_addition_module --with-http_dav_module
--with-http_geoip_module --with-http_gzip_static_module
--with-http_image_filter_module --with-http_realip_module
--with-http_stub_status_module --with-http_ssl_module
--with-http_sub_module --with-http_xslt_module --with-ipv6
--with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl
--with-mail --with-mail_ssl_module
--add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-auth-pam
--add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-echo
--add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-upstream-fair
--add-module=/tmp/buildd/nginx-1.1.19/debian/modules/nginx-dav-ext-module

I'm using nginx 1.1.19-1~bpo60+1 package from Debian squeeze backports.

Any idea please?
Is there anything else I can report?

Gregory



More information about the nginx mailing list