We have a upload system that is working behind a nginx reverse proxy, the system checks the authentication before starting to stream the request body from the client (passing through nginx) to the storage system, if the authentication failed, the backend doesn't stream the body but returns directly the HTTP 401 with a Connection: close
header.
When testing authentication failure to the backend directly, as expected the connection is closed if the authentication failed and the payload is not uploaded, however when putting the backend behind nginx, I do see the backend sending back the 401 to nginx, but nginx wait for the whole request body to be received to send back the 401 (and the Connection: close
) to the client (so potentially accepting multi gigabit files for nothing).
Is there a way to force nginx to stop receiving the body and directly respond to the client ? The current behaviour is an issue as it's wasting potentially a lot of bandwitdh and generating a lot of load on the nginx.
I tried to disable the keepalived but no luck
This is what I use for testing (httpie):
http --form --auth wrongtoken: POST http://localhost/upload [email protected]