I'm running nginx/ruby-on-rails and I have a simple multipart form to upload files.
Everything works fine until I decide to restrict the maximum size of files I want uploaded.
To do that, I set the nginx
The problem is that when I upload a 1.2 MB file, instead of displaying the HTTP 413 error page, the browser hangs a bit and then dies with a "Connection was reset while the page was loading" message.
I've tried just about every option there is that nginx offers, nothing seems to work. Does anyone have any ideas about this?
Here's my nginx.conf:
error_page 404 /404.html;
error_page 413 /413.html;
nginx "fails fast" when the client informs it that it's going to send a body larger than the
client_max_body_size by sending a 413 response and closing the connection.
Most clients don't read responses until the entire request body is sent. Because nginx closes the connection, the client sends data to the closed socket, causing a TCP RST.
If your HTTP client supports it, the best way to handle this is to send an
Expect: 100-Continue header. Nginx supports this correctly as of 1.2.7, and will reply with a
413 Request Entity Too Large response rather than
100 Continue if
Content-Length exceeds the maximum body size.