Hello!
On Wed, Mar 13, 2013 at 8:35 AM, Vincent Chavelle wrote:
> I'm trying to use your module: ngx-lua-upload. And it works as expected,
> thanks for your great work.
It is my pleasure :)
> But I have an issue when I trying to make a call to ngx.location.capture
>
> nginx.conf :
>
> location /api/new.json {
> content_by_lua '
> bla = ngx.location.capture("/api/persist.json", { method =
> ngx.HTTP_POST, body = "I AM A TEST BODY" });
> ';
> }
>
> location / {
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto $scheme;
> proxy_set_header Host $http_host;
> proxy_redirect off;
>
> proxy_pass http://localhost:20559; # redirect to pow
> }
>
> But I can't access the body in rails :
>
> def persist
> logger.info("PARAMS: #{params}")
> logger.info("BODY: #{request.raw_post} #{request.body.read}")
> end
>
> Started POST "/api/persist.json" for 127.0.0.1 at 2013-03-13 16:23:17 +0100
> Processing by ApiController#persist as JSON
> PARAMS: {"controller"=>"api", "action"=>"persist", "format"=>"json"}
> BODY:
>
> Do you have any idea ? The ngx.location.capture with GET are fine.
> I use nginx-1.3.14, ngx_devel_kit-0.2.18, lua-nginx-module-0.7.17
>
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.
BTW, you're strongly recommended to join the openresty-en mailing list
and post such questions there:
https://groups.google.com/group/openresty-en
As you can tell, I cannot always catch up all the user emails and it's
good to get help from the community when I'm really busy :)
Best regards,
-agentzh