Hi,
This is not possible. Only one *_by_lua_block of each type (rewrite,
access, etc...) will be executed for each request. This is by design.
You have to handle such cases in your own Lua business logic. There are
**numerous** threads both in this email list and on the ngx_lua
repository issues[1] discussing this topic.
Best,
Thibault
[1]: https://github.com/openresty/lua-nginx-module
On 5/9/19 7:19 PM, Zaar Hai wrote:
> Good day guys,
>
> I designing new API where I would like to perform two-stage authorization:
>
> server {
> listen 8000;
>
> access_by_lua_block {
> -- First stage authz for everybody
> }
>
> location /foo {
> # No additional access verification
> proxy_pass ...
> }
>
> location /bar {
> access_by_lua_block {
> -- Second stage authz just for this location
> }
> proxy_pass ...
> }
> }
>
> However I discovered that only one access_by_lua_block will run per
> request (or so it seems) - if I access /foo then "First stage" will run
> as expected, however if I access /bar then *only* "Second stage" runs.
> Is this by design? Is there a way to chain them? Or call outer
> access_by_lua_block from the inner one?
>
> Thank you,
> Zaa.