Ningx/Django Bad Request Error - Partial SOLUTION

Henry Ward henry.ward at
Wed Jan 18 19:24:22 UTC 2012

Hi Valentin,

Thanks for the ideas.  I did the curl as you suggested and that works.  You were right that it is something wrong with the POST request using Python urllib.  I tried both request and httplib with urlib and neither worked.  The only thing that worked was a command line curl.

I checked the error path and all the settings and I am still unable to get this error to diagnosis further.  I am getting other errors in the log but not this one. 

I've never seen this problem before with Apache or django run server and it there is not much in the google searches about this.  Though I can hack the client with command like curl for now this seems Nginx issue that will reappear.


On Jan 18, 2012, at 9:54 AM, Valentin V. Bartenev wrote:

> On Wednesday 18 January 2012 20:58:48 you wrote:
> [...]
>> Error Log
>> The error log shows nothing.  Literally.  The access_log shows the access
>> url and the 400 error.  But the error log does not.  I know that is hard
>> to believe its similar to what is said here:
> Did you set a correct path to error log in main context (not that one in your 
> server section) and debug level? Did you configure and build nginx with debug?
> [...]
>> This is what makes so irritatingly difficult to debug.  It is also I feel
>> it some type of permission error or setting that does not allow POST
>> requests.  I've also read here ( that Nginx
>> by default only allows GET requests but I couldn't find anywhere where the
>> is verified nor how to enable that.
> ## Only allow GET and HEAD request methods. By default Nginx blocks
> ## all requests type other then GET and HEAD for static content.
> If you read carefully, you will notice "for static content". That means files in 
> your filesystem, obviously, cuz they can't process POST.
> Actually, I expect that you POST request is just broken. It's ok for primitive 
> django builtin http-server, but it isn't acceptable for nginx. 
> Why don't you use simple curl for emulate request? Please, try curl.
> Or, it may be a django error, cuz of misconfigured fastcgi-param.
> Why don't you use stock fastcgi-params config that distributed with nginx? 
> [...]
>> I have also created application logging in Django and have "GOT HERE" log
>> statement in the first line of the view that handles the POST request.. 
>> That line never gets called so it appears Nginx is kicking out the request
>> before it ever passes to the django app.
> No. It just means that your request didn't reach the view, that handles POST 
> requests. Probably, because of misconfigured fastcgi-param django receive wrong
> or incomplete params.
> Anyway, please, investigate and fix your problem with debug log. There's no 
> magic.
> wbr, Valentin V. Bartenev

More information about the nginx mailing list