Welcome! Log In Create A New Profile

Advanced

Re: Modify request body before sending to upstream

January 27, 2015 02:14AM
Nevermind my previous post. I solved it finally :)


location /foo {
rewrite_by_lua '
res = ngx.location.capture("/bar", {method = ngx.HTTP_POST, body = "jjj"})
res = ngx.location.capture("/bar", {method = ngx.HTTP_POST, body = res.body})
ngx.print(res.body)
';
}

location /bar {
proxy_pass http://wservers;
}



[vm ~]$ curl localhost:8080/bar -X POST --data 'hello'
UPSTREAM: hello :UPSTREAM
[vm ~]$ curl localhost:8080/foo -X POST --data 'hello'
UPSTREAM: UPSTREAM: jjj :UPSTREAM :UPSTREAM


Thank you so much!! You saved me a lot of time.
Subject Author Posted

Modify request body before sending to upstream

abhinanda January 21, 2015 05:47AM

Re: Modify request body before sending to upstream

abhinanda January 26, 2015 10:08PM

Re: Modify request body before sending to upstream

mex January 27, 2015 01:10AM

Re: Modify request body before sending to upstream

abhinanda January 27, 2015 01:20AM

Re: Modify request body before sending to upstream

mex January 27, 2015 01:29AM

Re: Modify request body before sending to upstream

abhinanda January 27, 2015 02:06AM

Re: Modify request body before sending to upstream

abhinanda January 27, 2015 02:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready