обработка nginx-ом stderr полученного от fastcgi сервера
Alexandr Gevlichenko
Alexandr.Gevlichenko at talkshor.com
Thu Nov 27 18:51:40 MSK 2008
Работает связка nginx+php-fpm.(nginx 7.22, centos 5.2)
При получении от php-fpm сообщений в stderr(warnings¬ice) nginx не верно обрабатывает их, поведение напоминает переполнение буфера для stderr.
Вот пример php скрипта который воспроизводит ошибку:
<?php
$array = array();
for ($i = 1; $i < 20; $i++)
{
if ( $array[$i] == 1) {
print "test\n";
}
}
print "done\n";
?>
При $i<20 работает как положено, в лог ошибок пишется:
2008/11/27 18:40:19 [error] 5656#0: *4218 FastCGI sent in stderr: "PHP Notice: Undefined offset: 1 in /home/www/host/nginx.php on line 6
PHP Notice: Undefined offset: 2 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 3 in /home/www/host/htdocs/nginx.php on line 6
........................
PHP Notice: Undefined offset: 18 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 19 in /home/www/host/htdocs/nginx.php on line 6" while reading response header from upstream, client: 193.201.80.94, server: host, request: "GET /nginx.php HTTP/1.1", upstream: "fastcgi://127.0.0.1
При 40 итерациях в логе:
2008/11/27 18:44:50 [error] 5656#0: *4262 FastCGI sent in stderr: "PHP Notice: Undefined offset: 1 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 2 in /home/www/host/htdocs/nginx.php on line 6
....................
PHP Notice: Undefined offset: 20 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 21 in /home/www/host/
При 200 итерациях:
2008/11/27 18:47:25 [error] 5656#0: *4285 FastCGI sent in stderr: "PHP Notice: Undefined offset: 1 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 2 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 3 in /home/www/host/htdocs/nginx.php on line 6
....................
PHP Notice: Undefined offset: 20 in /home/www/host/htdocs/nginx.php on line 6
PHP Notice: Undefined offset: 21 in /home/www/host/
2008/11/27 18:48:25 [error] 5656#0: *4285 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 193.201.80.94, server: host, request: "GET /nginx.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "host"
--
Best Regards,
Alexandr Gevlichenko
More information about the nginx-ru
mailing list