Clientbodyinfileonly - POST request is discarded

Francis Daly francis at
Sun Oct 9 16:05:07 UTC 2016

On Fri, Oct 07, 2016 at 03:47:47PM -0400, yurai wrote:

Hi there,

> Unfortunately still it doesn't work as I expect - upload.txt file content is
> not saved on server side in /tmp/nginx-client-body.

Oh. Why do you expect that?

I would only expect that to happen if I send the upload.txt file content,
which I have not done yet.

> My understanding is that transfer should be performed in 2 phases (2 POST
> requests via 2x curl).


Each request is completely independent of each other request. If you
want to tie two together, you must add the tying part yourself. (Or use
a framework which does it for you).

> First request should deliver file name, and second
> should deliver actual file content without ingeration from backend side. I
> analyzed HTTP flow in wireshark and it looks fine for me (details below).
> 1. curl --data-binary upload.txt http://localhost/upload
> - s1 listening on 80 recive POST request with body = "upload.txt". S1 buffer
> "upload.txt" in /tmp/0000001, generate new POST request with field
> X-FILE="/tmp/0000001" and pass this request to backend (s2)
> - s2 listening on 8080 recieve POST request with  X-FILE = "/tmp/0000001"
> - s2 generate HTTP response 200 with body = "Do something sensible with
> /tmp/0000001\n" and pass it to s1
> - s1 recieve above response and pass it to client
> - client recieve HTTP response 200 with body = "Do something sensible with
> /tmp/0000001\n"

Yes, that is exactly what should happen.

Except that you seem to have switched between /tmp and
/tmp/nginx-client-body somewhere.

> 2. curl --data-binary '@upload.txt' http://localhost/upload  

This should do exactly the same as the first one, except that now
(because of what the curl client does) the POST data is not the string
"upload.txt", but is instead the content of the file upload.txt.

nginx has no idea that the content came from a file, or what that filename
might have been.

> If I understand this mechanism correctly now actual upload.txt transfer to
> server without backend ingeration should be triggered.
> So I should get reponse 200 and upload.txt content should be saved by server
> under /tmp/nginx-client-body.

You should get something like response 200 with body = "Do something
sensible with /tmp/0000002\n", exactly the same format as the first
response (but with a different filename.)

nginx receives a POST with some body content. nginx writes that body
content to a new file in its client_body_temp_path

> Anyway when I type curl --data-binary '@upload.txt' http://localhost/upload
> whole scenario from previous point is performed again.

What is the filename that you get back in the response? What is the
content of that file, when you look on the server?

It looks to me like everything is working as intended. I have a file
/tmp/nginx-client-body/0000000005 which contains the contents of my
upload.txt, and I have a file /tmp/nginx-client-body/0000000004 which
contains the 10 characters "upload.txt".

If you do not have that, what specifically do you have instead?

Francis Daly        francis at

More information about the nginx mailing list