Clientbodyinfileonly - POST request is discarded

yurai nginx-forum at forum.nginx.org
Fri Oct 7 19:47:47 UTC 2016


Hi Francis,
I added return statement to my config as you suggested. Now config for
backend s2 looks like:

 server {
        listen       8080;
        server_name  s2;

        location / {
            root   /usr/share/nginx/html/foo/bar;
            return 200 "Do something sensible with $http_x_file\n";
            autoindex on;
        }
    }

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

My understanding is that transfer should be performed in 2 phases (2 POST
requests via 2x curl). 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"

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

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

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,270063,270122#msg-270122



More information about the nginx mailing list