Nginx error 403 on file upload – passing multipart/form-data to the proxy/server

nginxupload

I have a very simple Nginx server that forwards traffic from subdomain to my http server on port 8000 like so :

server {
    listen       80;
    server_name *.localhost;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host            $host;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}

My http server then takes care of everything by reading the hostame etc and it's working fine for any basic api/json requests.

Now i'm trying to send a file to my server but get a 403 error from nginx on sending the file / multipart form data.

From reading the doc i'm a bit confused as " upload_pass_args " seems to require a dedicated route configured in the conf file and that's not something i want at all. I just need the multipart / form data passed to my server's router to be handled ( the http server on :8000 )

I've also try to include sendfile on; in both my server{} or inside location{} but to no success.

Best Answer

proxy_request_buffering off; will fix the issue.

From reading this answer i suspect a proper configuration of the buffer would be the way to go when i've tried/done that i'll try to update this answer.