Nginx postgres problem
Yichun Zhang (agentzh)
agentzh at gmail.com
Wed Mar 5 19:58:01 UTC 2014
Hello!
On Wed, Mar 5, 2014 at 8:39 AM, arunh wrote:
> I had to make a series of postgres calls so I used content_by_lua along by
> sharing the varialbes as I had to query tables from multiple databases.
>
No, you should use rewrite_by_lua exclusively for all the
ngx.location.capture calls here I think.
> I have now got the needed nodeIP and port ultimately. But I am not able to
> redirect the url.
> I have used rewrite_by_lua in the end to redirect to the new url, but it
> does not seem to be happening.
rewrite_by_lua always runs before content_by_lua. Because NGINX's
"rewrite" phase always runs before the "content" phase.
Just put all your subrequest calls in the same code chunk as your
redirect Lua code in rewrite_by_lua.
What kind of redirect do you really need? 301? 302? or internal redirect? See
https://github.com/chaoslawful/lua-nginx-module#ngxredirect
https://github.com/chaoslawful/lua-nginx-module#ngxexec
Speaking of running order, I suggest you read my NGINX tutorials to
prevent such confusions:
http://openresty.org/download/agentzh-nginx-tutorials-en.html
BTW, you're recommended to join the openresty-en mailing list and
discuss such things there:
https://groups.google.com/group/openresty-en You might get faster and
more responses on that list.
Best regards,
-agentzh
More information about the nginx
mailing list