Hi Dan, thanks for the report.
On Thu, Oct 20, 2022 at 09:04:31AM -0400, Dan G. Switzer, II wrote: > 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. [...] > However, if I change the code to: > > > 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; > > } > > 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? 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 http://127.0.0.1/upload/11k <html> <body> here's the 413 error </body> </html> Thank you. -- Sergey A. Osokin _______________________________________________ nginx mailing list -- nginx@nginx.org To unsubscribe send an email to nginx-le...@nginx.org