<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font face="Helvetica, Arial, sans-serif">Sorry, that was a typo
      from the tweak to the real file names. The file extensions matched
      in my test and I got the custom 404 error page.</font><br>
    <br>
    <div class="moz-cite-prefix">On 10/20/2022 4:22 PM, Frank Swasey
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAGcNPZ0wrNqwjrfJDmRm8MhGwNG+Enw_Fq2-k755Xqj-wCZCSw@mail.gmail.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div dir="auto">You do realize you redirected to <name>.htm
        and specified <page>.html in the location, right?</div>
      <div dir="auto"><br>
      </div>
      <div dir="auto"><br>
      </div>
      <div><br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Thu, Oct 20, 2022 at
            14:02 Dan G. Switzer, II <<a
              href="mailto:dan.switzer@givainc.com"
              moz-do-not-send="true" class="moz-txt-link-freetext">dan.switzer@givainc.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div> <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>On 10/20/2022 11:05 AM, Sergey A. Osokin wrote:<br>
              </div>
              <blockquote type="cite">
                <pre>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>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>[...]

</pre>
                <blockquote type="cite">
                  <pre>However, if I change the code to:

</pre>
                  <blockquote type="cite">
                    <pre>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>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>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 href="https://url.emailprotection.link/?bBgKrp4MmqsBU6w4TjxZ9_JqJd9V0NDmTOHlOJxvE4o6VBzwgW7OP1tEufUK7BpJqJXzp1a-EKqVvPqu_3UYV0A~~" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://url.emailprotection.link/?bBgKrp4MmqsBU6w4TjxZ9_JqJd9V0NDmTOHlOJxvE4o6VBzwgW7OP1tEufUK7BpJqJXzp1a-EKqVvPqu_3UYV0A~~</a>
<html>
<body>
here's the 413 error
</body>
</html>

Thank you.

</pre>
              </blockquote>
              <br>
              <pre cols="72">-- 
Dan G. Switzer, II
Giva, Inc.
Email:    <a href="mailto:dan.switzer@givainc.com" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">dan.switzer@givainc.com</a>
Web Site: <a href="https://url.emailprotection.link/?bhjBYMqDY4Ztp4avwgwh-mfk6NkHsmC1wbas7UBcaAeFD3u9uFgGS2UeqToAsqzSIdZftmRn6Fqh9GTxM-n924A~~" target="_blank" moz-do-not-send="true">http://www.givainc.com</a>

See Our Customer Successes 
<a href="https://url.emailprotection.link/?bQFudat7_sfP7dfaw5blL1Fd_nJ2I93M6XjiAQOSV9FDvdHniCzGbxIo47iEiDZACk_KRZBygM1CmQRz78brGlxzQq_m40Fkq7z6b8bOipFBJSIFaa9-rofFRkLRLhYPE" target="_blank" moz-do-not-send="true">http://www.givainc.com/customers-casestudies.htm</a>
</pre>
            </div>
            _______________________________________________<br>
            nginx mailing list -- <a href="mailto:nginx@nginx.org"
              target="_blank" moz-do-not-send="true"
              class="moz-txt-link-freetext">nginx@nginx.org</a><br>
            To unsubscribe send an email to <a
              href="mailto:nginx-leave@nginx.org" target="_blank"
              moz-do-not-send="true" class="moz-txt-link-freetext">nginx-leave@nginx.org</a><br>
          </blockquote>
        </div>
      </div>
      -- <br>
      <div dir="ltr" class="gmail_signature"
        data-smartmail="gmail_signature">I am not young enough to know
        everything. - Oscar Wilde (1854-1900)</div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
nginx mailing list -- <a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
To unsubscribe send an email to <a class="moz-txt-link-abbreviated" href="mailto:nginx-leave@nginx.org">nginx-leave@nginx.org</a>
</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>