Bug: custom error_page doesn't work for HTTP 413 (content too large)
Igor Sysoev
is at rambler-co.ru
Tue Sep 1 12:58:11 MSD 2009
On Mon, Aug 31, 2009 at 05:25:45PM +0000, Peter Vandenberk wrote:
> Hi Igor,
>
> Igor Sysoev <is at ...> writes:
> > The attached patch should fix the bug.
>
> Thanks for the quick reply to my question, and for taking the time
> to supply a patch... much appreciated!
>
> The patch works like a charm... thanks for that! I forgot to mention
> that we are running the "legacy" 0.6.xx version of nginx, so I have
> attached a slightly modified version of your patch with the correct
> diff context (esp. line numbers) for that version of the code base.
Yes, the patch should work for 0.6.x too.
> Igor Sysoev <is at ...> writes:
> > However, browsers usually show the 413 error page only after they have sent
> > a whole request body. Therefore on slow connection and with large body
> > browsers will show some network error or "this page cannot be displayed" page.
>
> Yes, thanks for the heads up... some of our users have indeed reported
> that behaviour to us as well, but quite a few also get a proper 413 response,
> which is why we are so eager to implement a custom 413 error page.
You may increase
lingering_time 30s; # default
lingering_timeout 5s; # default
lingering_time sets how long nginx will read discarded body before closing
connection. lingering_timeout is timeout between two read() operation.
If client did not send anything during this time, then nginx closes
connection.
> Thanks again for your time and the patch!
>
> Peter
>
> ===
>
> *** src/http/ngx_http_core_module.orig 2009-08-31 18:10:46.000000000 +0100
> --- src/http/ngx_http_core_module.c 2009-08-31 18:11:26.000000000 +0100
> ***************
> *** 859,864 ****
> --- 859,865 ----
> "client intended to send too large body: %O bytes",
> r->headers_in.content_length_n);
>
> + (void) ngx_http_discard_request_body(r);
> ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
> return NGX_OK;
> }
>
>
>
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list