See http://wiki.nginx.org/Phases
access_by_lua sits in the access phase; your lua code will run, and if
the transaction doesn't quit, it will get passed down to the next phases
(eventually the content phase, where proxy_pass sits). The lua code
doesn't call proxy_pass, that gets handled by the nginx worker itself.
If you don't want to proxy_pass if you meet a given condition, you can
ngx.say() your capture, then ngx.exit(200) to stop transaction
processing (instead of the return you have now)
On 06/26/2014 03:58 AM, Peter G wrote:
> If i use access_by_lua will it not call proxy_pass ?
>
> On Wednesday, June 25, 2014 10:39:36 PM UTC+5:30, rpaprocki wrote:
>
> Hi,
>
> From the Ngxinx Lua API documentation:
>
> Do not use this directive and other content handler directives in
> the same location. For example, this directive and the proxy_pass
> <http://wiki.nginx.org/HttpProxyModule#proxy_pass> directive should
> not be used in the same location.
>
> You should use access_by_lua instead of content_by_lua.
>
> On 6/25/2014 05:21, Peter G wrote:
>> Hi
>>
>> Basically i want to do some safety check before doing proxy_pass
>>
>> For example, Lets say I want to block all the PUT methods.
>>
>> So my code is like this
>>
>> location / {
>>
>> content_by_lua '
>> --Blah blah
>> if my_condition then
>> res =
>> ngx.location.capture("/gohere")
>> ngx.say(res.body)
>> return
>> ';
>>
>> proxy_pass http://myupstream;
>> }
>>
>>
>> AS you can see, I want to first check for some condition and go to
>> alternate locataion which handles say errors. Only in else
>> condition I want to do proxy_pass.
>>
>> I am seeing that Irrespective of my condition, IT is always doing
>> proxy_pass :(
>>
>> What am i missing here ?.