1

On validating user input into my api, I want to return 400 http status codes for bad requests. It works fine from flask and when running my api through gunicorn, but they always come out of nginx as 500 errors. my site config is the following:

server {
    listen 80;

    server_name *****;

    access_log  /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log;

    location / {
        proxy_pass         http://localhost:8000/;
        proxy_redirect     off;

        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

any ideas on solutions would be very appreciated. Thanks.

bcollins
  • 113
  • 5
  • 3
    Does the `/var/log/nginx/error.log` say anything? – mike Jul 25 '14 at 15:08
  • nothing in the nginx error log or the gunicorn error log – bcollins Jul 25 '14 at 15:50
  • 1
    If the actual request is processed and returns 500, then you should probably paste your API code because it seems that the 500 error is coming from your API code, not nginx. – mike Jul 25 '14 at 20:00
  • turned out I had a rogue gunicorn process running. The error was indeed on the api code side. After a reboot all was fine. Thanks for your help – bcollins Aug 11 '14 at 20:58

0 Answers0