lua-nginx-module
lua-nginx-module copied to clipboard
content_by_lua and access_by_lua not executing in mirror block
Hello,
I'm having trouble running either content_by_lua_block or access_by_lua_block inside a mirror block.
This is my configuration
server {
listen 8888;
server_name *;
proxy_connect;
proxy_max_temp_file_size 0;
resolver 8.8.8.8;
location / {
mirror /mirror;
access_by_lua_block {
ngx.log(ngx.ERR, "Hello world 1")
}
proxy_pass http://127.0.0.1:8080;
}
location /mirror {
access_by_lua_block {
ngx.log(ngx.ERR, "Hello world 2")
}
proxy_pass http://127.0.0.1:8090$request_uri;
internal;
}
}
In my error.log file I can see the text "Hello world 1", but not "Hello world 2". I know that the /mirror block is being accessed correctly because I'm monitoring it with Wireshark.
Please let me know if you need any more information.
Versions: OpenResty 1.17.8.2 nx_lua 0.10.17
Dump of openresty -V
nginx version: openresty/1.17.8.2
built by gcc 9.3.0 (Alpine 9.3.0)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt=-O2 --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.32 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.08 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.17 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.15 --add-module=../rds-csv-nginx-module-0.09 --add-module=../ngx_stream_lua-0.0.8 --with-ld-opt=-Wl,-rpath,/usr/local/openresty/luajit/lib --add-module=/usr/src/chobits-ngx_http_proxy_connect_module-96ae4e0 --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_ssl_module
+1 , same issue here.
please refer to README.markdown, line 2277 As with other access phase handlers, access_by_lua_block will not run in subrequests
Mirror module create a background subrequest, so access_by_lua_block will not be executed. I try content_by_lua_block{}, it works well.