Hi All,
I am trying to setup a configuration where I am doing proxy_pass at one location. But, there are different locations that point at it. I want to add some validations before calling the particular location. I want to run basic check and then redirect the request to the main location. But, if I use rewrite, access_by_lua doesn't run. I did read about access_by_lua not being called for subrequests. But, if the first call directly hits a block with access_by_lua that should not be considered a subrequest. Is that understanding correct?
Example -
server {
listen 4000;
location ~ ^/hello/world/(.*)$ {
set $path $1;
access_by_lua_block {
ngx.log (ngx.NOTICE, "in Lua")
ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
}
rewrite ^ /$path last; # access_by_lua doesn't run
proxy_pass http://google.com?q=$channel; # access_by_lua does run
}
location ~ foo {
return 200 "bar";
}
}
curl localhost:4000/hello/world/foo
200
bar
I would appreciate any insights here.