I have a small Django (1.2.x) project deployed on Apache (2.x) via mod_wsgi (3.x). In the admin, if I upload a file < 1MB, I can get it through; however, for a file, say, 1.2MB in size, I get a 400 response from the server with "Error 400" in the body only. I am wondering why this is happening. As far as I can see, there is no LimitRequestBody
set in Apache configuration. I have tried uploading with several browsers including: Firefox, Chrome, and Safari.
In the log file for Apache, there is apparently no entry for requests that gave the 400 error response. This is strange.
I should point out that the scenario where this is happening is thus: The project in question is deployed on two identical Apache servers (completely identical setup) that are behind a load balancer. On my development setup, of course, the problem does not surface.
Any help with this will be very much appreciated.
UPDATE: I have found out that the following error message is logged for the load balancer: Bad request headers : Content-length exceeds post body limit
. The other interesting bit is that, if the file > 1 MB is uploaded over HTTPS, it goes through fine. However, when it is uploaded over HTTP, it gives out the 400 error.
UPDATE #2: I decided to write a simple file upload program using simply Python and web.py. I got it to be deployed on the production server under the same virtual host configurations, under mod_wsgi
. The file uploads worked when the application was served over SSL. But they gave the Error 400
when they were served over non-SSL. So, I am even more stumped than before.
I am going to answer this myself as the problem has been resolved. Thanks very much to both Redmumba and Graham Dumpleton for their comments.
The problem was certainly not with Django (as we had already established). However, it turned out not to be with Apache. The problem was with the firewall on the system that the system admins had forgotten about completely (sigh). Apparently, the firewall had a file size limit of 1MB imposed.