waiting for full request
Maxim Dounin
mdounin at mdounin.ru
Thu Sep 8 14:36:42 UTC 2022
Hello!
On Wed, Sep 07, 2022 at 09:01:05AM -0400, mirokub wrote:
> Hello,
> Is there a way to configure NGINX to send response (200 OK) only after full
> body of request is delivered?
> Currently the response is sent early before the request body is fully sent.
> More details of my test-case: The request is about 600kB long and it's POST
> method.
The response is sent by nginx when it's available. For static
files and rewrite constructs like "return 200 ok;" this happens
right after the request headers are received, so nginx doesn't try
to wait for the request body before sending the response. In some
cases this might save the client from sending unneeded body to
nginx.
If for some reason you want nginx to only respond when the whole
request body is received, the readily available solution would be
to configured nginx in a way which needs the whole response body
before sending the response. For example, you can configure
additional proxying with proxy_request_buffering switched off (the
default), so nginx will read the whole request body before
proxying the request (and returning the response from the upstream
server):
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8081;
}
}
server {
listen 127.0.0.1:8081;
return 200 ok;
}
Hope this helps.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list