nginx 0.8.47 php-fpm error_page not working

Igor Sysoev igor at sysoev.ru
Mon Aug 9 17:36:56 MSD 2010


On Mon, Aug 09, 2010 at 09:11:27AM -0400, nginx_newbie wrote:

> Dear Igor,
> 
> Thanks for taking the time to look into my problem!
> Since I wanted error404.htm to be parsed by PHP, I removed the
> error_page line
> and corresponding location block from the configuration file and placed
> a new
> error_page line within the location block that is passing all HTM files
> to PHP
> 
> While at present error404.htm is plain html file, it will ultimately by
> a PHP file later.
> On slowly trying to understand the debug output, I see that nginx is
> going all the way
> to evoke parsing error404.htm and also send in the headers to the
> browser. But nothing
> is visible there after. All that I get on the browser (Google Chrome) as
> output is standard
> error from Chrome "Oops! This link appears to be broken.".
> 
> Since the problem still remains unsolved, I am attaching the fresh
> server config
> file for your reference along with the debug output after all these
> changes.

PHP has returned 404:

> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi header: "Status:
> 404 Not Found"

nginx has redirected the 404 to "/error404.htm":

> 2010/08/09 18:26:13 [debug] 19232#0: *7 internal redirect:
> "/error404.htm?"

It's passed to PHP:

> 2010/08/09 18:26:13 [debug] 19232#0: *7 fastcgi param: "SCRIPT_FILENAME:
> /srv/www/mutually4u.com/public_html/error404.htm"

PHP has returned 170 bytes including header and page itself:

> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi record length: 170
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi parser: 0
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi header:
> "X-Powered-By: PHP/5.2.14"
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi parser: 0
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi header:
> "Content-type: text/html"
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi parser: 1
> 2010/08/09 18:26:13 [debug] 19232#0: *7 http fastcgi header done

nginx returns 404 code with PHP page to client:

> 2010/08/09 18:26:13 [debug] 19232#0: *7 HTTP/1.1 404 Not Found
> Server: nginx/0.8.47
> Date: Mon, 09 Aug 2010 12:56:13 GMT
> Content-Type: text/html
> Transfer-Encoding: chunked
> Connection: keep-alive
> X-Powered-By: PHP/5.2.14
> Content-Encoding: gzip

Chrome recently(?) started to show its own "friendly" error page as MSIE
does if error page is shorter than 512 bytes. nginx appends several
lines:
"<!-- a padding to disable MSIE and Chrome friendly error page -->"
to its internal error pages to increase page size, if the "msie_padding"
directive is on (by default). Try to look in other browser or try to add
some comment lines to your pages.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list