Welcome! Log In Create A New Profile

Advanced

Re: ngx_lua + proxy_next_upstream

Jedrzej Nowak
September 24, 2013 05:36AM
Ok, I still have some problems. It works but not perfectly.

My config is:

location /test {
internal;
rewrite /test(.*) $1 break;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_connect_timeout 10;
proxy_send_timeout 30;
proxy_read_timeout 30;
proxy_pass http://$upstream;
}

location / {
set $upstream "";
set $app_name "";
content_by_lua_file conf/lua_proxy.lua;
}

The question is how can I do NOT redirect ? I tried with @test instead of
/test but no success. Is there any other way to do that ?

lua looks like:

[...]
ngx.var.upstream = "192.168.1.10:9999"
res = ngx.location.capture('/test' .. ngx.var.request_uri,
{share_all_vars = true})
[...]


Pozdrawiam
Jędrzej Nowak


On Mon, Sep 23, 2013 at 9:16 AM, Jedrzej Nowak <pigmej@gmail.com> wrote:

> Hey,
>
> Thanks for your reply. Is there any good "example" of thing what I want to
> archive ?
>
> Shall I create something like:
>
> location @blah {
>
> # here the "normal" configuration for LB
>
> }
>
>
> location / {
>
> # here the LUA logic
>
> # probably with share_all_vars=true
>
> # subrequest to @blah
>
> }
>
>
> Is something like that recommended or how should it be done ?
>
> Pozdrawiam
> Jędrzej Nowak
>
>
> On Fri, Sep 20, 2013 at 2:34 AM, Yichun Zhang (agentzh) <agentzh@gmail.com
> > wrote:
>
>> Hello!
>>
>> On Wed, Sep 18, 2013 at 6:09 AM, Jedrzej Nowak wrote:
>> > The question is how can I archive proxy_next_upstream.
>> > Preferably I would like to return to lua with a error reason.
>> > If the only way is to return several servers in upstream from lua, how
>> to do
>> > so ?
>> >
>>
>> If you want to return the control back to Lua and let your Lua code do
>> the upstream retries or something, then you should use the
>> ngx.location.capture() API instead to initiate an Nginx subrequest to
>> ngx_proxy:
>>
>> http://wiki.nginx.org/HttpLuaModule#ngx.location.capture
>>
>> Regards,
>> -agentzh
>>
>> _______________________________________________
>> nginx mailing list
>> nginx@nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

ngx_lua + proxy_next_upstream

Jedrzej Nowak September 18, 2013 09:10AM

Re: ngx_lua + proxy_next_upstream

Yichun Zhang (agentzh) September 19, 2013 08:36PM

Re: ngx_lua + proxy_next_upstream

Jedrzej Nowak September 23, 2013 03:18AM

Re: ngx_lua + proxy_next_upstream

Jedrzej Nowak September 24, 2013 05:36AM

Re: ngx_lua + proxy_next_upstream

Yichun Zhang (agentzh) September 24, 2013 04:30PM

Re: ngx_lua + proxy_next_upstream

Anonymous User September 24, 2013 06:40PM

Re: ngx_lua + proxy_next_upstream

Yichun Zhang (agentzh) September 25, 2013 02:22AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 328
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