Thanks for your reply, I finally investigate and the problem comes from Content-Type header.In my case the first request has the followingContent-Type: multipart/form-data; boundary=cpcaupipxvqdfnsrxugwvraaudntfpal And ngx.location.capture pass the same header to the subrequest.I have tried to use ngx.header for override it but doesn't seems to work.Do you have any idea to ignore content-type header from the request ? Thanks I tested your Nginx configuration locally by running nc to listen on the 20559 port: nc -l 20559 And when accessing /api/new.json, I'm getting the following raw HTTP request on the nc side: POST /api/persist.json HTTP/1.0 X-Forwarded-For: 127.0.0.1 X-Forwarded-Proto: http Host: localhost Connection: close Content-Length: 16 I AM A TEST BODY Looking perfectly good to me. You can try it out on your side or if your prefer, just grabbing the raw TCP packets via tools like tcpdump. It could be a problem on your Rails side though. This way you can rule it out.
I tested your Nginx configuration locally by running nc to listen on the 20559 port: nc -l 20559 And when accessing /api/new.json, I'm getting the following raw HTTP request on the nc side: POST /api/persist.json HTTP/1.0 X-Forwarded-For: 127.0.0.1 X-Forwarded-Proto: http Host: localhost Connection: close Content-Length: 16 I AM A TEST BODY Looking perfectly good to me. You can try it out on your side or if your prefer, just grabbing the raw TCP packets via tools like tcpdump. It could be a problem on your Rails side though. This way you can rule it out.