Welcome! Log In Create A New Profile

Advanced

Re: Nginx postgres problem

Yichun Zhang (agentzh)
March 05, 2014 03:00PM
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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Nginx postgres problem

arunh March 04, 2014 10:15AM

Re: Nginx postgres problem

Yichun Zhang (agentzh) March 04, 2014 06:20PM

Re: Nginx postgres problem

arunh March 05, 2014 11:39AM

Re: Nginx postgres problem

Yichun Zhang (agentzh) March 05, 2014 03:00PM

Re: Nginx postgres problem

Yichun Zhang (agentzh) March 05, 2014 03:04PM

Re: Nginx postgres problem

arunh March 05, 2014 05:21PM

Re: Nginx postgres problem

Yichun Zhang (agentzh) March 05, 2014 05:34PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 189
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready