404 -> 500

Igor Sysoev is at rambler-co.ru
Sun Aug 27 23:28:39 MSD 2006


On Sun, 27 Aug 2006, Alexander S. Zavdoveyeff wrote:

> On Sun, Aug 27, 2006 at 05:17:11PM +0300, Alexander S. Zavdoveyeff wrote:
>> On Sun, Aug 27, 2006 at 04:38:52PM +0300, Alexander S. Zavdoveyeff wrote:
>>> Добрый день!
>>> Есть nginx в роли front-end и apache в роли back-end.
>>> В nginx.conf присутствует в http:
>>>
>>> error_page 404 /404.html;
>>> error_page 403 /403.html;
>>> error_page 500 502 503 504 /50x.html;
>>>
>>> Есть server. В его конфигурации есть proxy_intercept_errors on.
>>>
>>> Запрашиваю несуществующий файл с домена. 404.html в root у server нет.
>>> В итоге отдаёт мне nginx не 404-ю ошибку, как должно быть, а 500-ю.
>>> Вот кусок debug-лога:
>>>
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http proxy header: "Date: Sun, 27 Aug 2006 13:26:02 GMT"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http proxy header: "Server: Apache/1.3.37 (Unix) PHP/5.1.4"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http proxy header: "Connection: close"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http proxy header: "Content-Type: text/html; charset=iso-8859-1"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http proxy header done
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 finalize http upstream request: 404
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 finalize http proxy request
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 close http upstream connection: 5
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 event timer del: 5: 1339019836
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http finalize request: 404, "/404.html?"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http special response: 404, "/404.html"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http set discard body
>>> 2006/08/27 16:26:02 [error] 1671#0: *27262 rewrite or internal redirection cycle while sending to client, client: 89.107.226.156
>>> , server: perec.org.ua, URL: "/stat/", upstream: "http://127.0.0.1:80/404.html", host: "perec.org.ua"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http finalize request: 500, "/404.html?"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http special response: 500, "/404.html"
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 http set discard body
>>> 2006/08/27 16:26:02 [debug] 1671#0: *27262 HTTP/1.1 500 Internal Server Error
>>> Server: nginx/0.3.60
>>> Date: Sun, 27 Aug 2006 13:26:02 GMT
>>> Content-Type: text/html
>>> Content-Length: 193
>>> Connection: close
>>>
>>> Если сделать proxy_intercept_errors off, то всё становится нормально,
>>> apache отдаёт свою 404-ю.
>>>
>>> Баг или фича?
>>>
>> Да, забыл.
>>
>> [root[p2]@first]:[17:15]#uname -srm
>> FreeBSD 6.1-RELEASE-p3 i386
>>
>> [root[p2]@first]:[17:15]#pkg_info | grep nginx
>> nginx-0.3.60        Robust and small WWW server
>>
> Я так понимаю, что это наследие ошибки, что вылезла в 0.3.59?

Да. Прилагаемый патч возращает вместо 500 последнюю ошибку, возникшую
перед циклом.


Игорь Сысоев
http://sysoev.ru
-------------- next part --------------
--- src/http/ngx_http_core_module.c	Fri Aug 18 18:08:58 2006
+++ src/http/ngx_http_core_module.c	Sun Aug 27 21:03:58 2006
@@ -1329,7 +1329,9 @@
     if (r->uri_changes == 0) {
         ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "rewrite or internal redirection cycle");
-        ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
+
+        ngx_http_finalize_request(r, r->err_status ? r->err_status:
+                                     NGX_HTTP_INTERNAL_SERVER_ERROR);
         return NGX_DONE;
     }
 


More information about the nginx-ru mailing list