<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<font face="Helvetica, Arial, sans-serif">Sergey,<br>
<br>
Thanks for taking the time to respond. That's not working for me.
I tried the following:<br>
<blockquote type="cite"><font face="Helvetica, Arial, sans-serif"><font
face="monospace"><br>
server {<br>
listen 80;<br>
<br>
client_max_body_size 10k;<br>
<br>
error_page 403 =404 /404_status_code.htm;<br>
error_page 404 =404 /404_status_code.htm;<br>
error_page 413 =413 /413_status_code.htm;<br>
<br>
location /upload {<br>
dav_methods PUT;<br>
create_full_put_path on;<br>
dav_access group:rw all:r;<br>
}<br>
<br>
location = /404_status_code.html {<br>
internal;<br>
root /path/to/my/custom/errors;<br>
}<br>
<br>
location = /413_status_code.html {<br>
internal;<br>
root /path/to/my/custom/errors;<br>
}<br>
}<br>
</font></font></blockquote>
<br>
The 404 works fine, but sending more than 10k to the request still
returns the default nginx page.<br>
<br>
If I curl to a non-existent URL, I get the custom 404. The 413
doesn't. If I remove the "internal" command, I can view the
/413_status_code.html file just fine.<br>
<br>
Is there a good way I can debug/troubleshoot why it might not be
working?<br>
<br>
It really seems like it might be a bug with the version of nginx
that CentOS 7 is installing.<br>
<br>
-Dan<br>
</font><br>
<div class="moz-cite-prefix">On 10/20/2022 11:05 AM, Sergey A.
Osokin wrote:<br>
</div>
<blockquote type="cite" cite="mid:Y1Fjt7KuHbKiLW0Y@FreeBSD.org.ru">
<pre class="moz-quote-pre" wrap="">Hi Dan,
thanks for the report.
On Thu, Oct 20, 2022 at 09:04:31AM -0400, Dan G. Switzer, II wrote:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">I'm using nginx/1.20.1 under CentOS Linux release 7.9.2009 (Core) and I
cannot get a custom error page to show when the client_max_body_size
limit has been exceeded. The browser will only return the default nginx
error page.
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
[...]
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">However, if I change the code to:
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">error_page 404 =404 /404_status_code.htm;
error_page 403 =404 /404_status_code.htm;
error_page 413 =413 /413_request_too_large.htm;
location /404_status_code.htm {
internal;
root /path/to/my/custom/errors/;
add_header X-Original-URL "$scheme://$http_host$request_uri" always;
}
location /413_request_too_large.htm {
internal;
root /path/to/my/custom/errors/;
add_header X-Original-URL "$scheme://$http_host$request_uri" always;
}
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
When I try to upload a file larger than my client_max_body_size setting,
I still get the default error page. I've tried a lot of different
variations of the code, but nothing seems to work.
Is there something special that needs to be done to implement a custom
error page for a 413 status code? Or is there perhaps a regression that
broke this from working?
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">
Here's the configuration that works here:
server {
listen 80;
client_max_body_size 10k;
error_page 403 =404 /404_status_code.html;
error_page 404 =404 /404_status_code.html;
error_page 413 =413 /413_status_code.html;
location /upload {
dav_methods PUT;
create_full_put_path on;
dav_access group:rw all:r;
}
location = /413_status_code.html {
internal;
root /usr/local/www/nginx;
}
}
% dd if=/dev/zero of=11k bs=1k count=11
11+0 records in
11+0 records out
11264 bytes transferred in 0.000075 secs (150232738 bytes/sec)
% cat /usr/local/www/nginx/413_status_code.html
<html>
<body>
here's the 413 error
</body>
</html>
% curl -T 11k <a class="moz-txt-link-freetext" href="https://url.emailprotection.link/?bBgKrp4MmqsBU6w4TjxZ9_JqJd9V0NDmTOHlOJxvE4o6VBzwgW7OP1tEufUK7BpJqJXzp1a-EKqVvPqu_3UYV0A~~">https://url.emailprotection.link/?bBgKrp4MmqsBU6w4TjxZ9_JqJd9V0NDmTOHlOJxvE4o6VBzwgW7OP1tEufUK7BpJqJXzp1a-EKqVvPqu_3UYV0A~~</a>
<html>
<body>
here's the 413 error
</body>
</html>
Thank you.
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Dan G. Switzer, II
Giva, Inc.
Email: <a class="moz-txt-link-abbreviated" href="mailto:dan.switzer@givainc.com">dan.switzer@givainc.com</a>
Web Site: <a class="moz-txt-link-freetext" href="http://www.givainc.com">http://www.givainc.com</a>
See Our Customer Successes
<a class="moz-txt-link-freetext" href="http://www.givainc.com/customers-casestudies.htm">http://www.givainc.com/customers-casestudies.htm</a>
</pre>
</body>
</html>