openresty / openresty/lua-nginx-module
'error_page' directive does not work under 'ngx.location.capture()'
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
'error_page' directive does not work under 'ngx.location.capture()'
Summary:
If the requested location has the 'error_page' configured and should be triggered (including default error_page), instead, the original code is returned with the truncated flag set to true
Environment Info:
- OpenResty version: not installed
- Nginx version:
nginx/1.12.2 - Nginx Lua Module version:
0.10.11rc2 - OS:
Linux 4.4.0-130-generic #156-Ubuntu SMP Thu Jun 14 08:53:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux - Nginx Build Flags:
Click me to collapse/fold.
These details will remain hidden until expanded.--prefix=/etc/ringcentral/nginx-test --sbin-path=/usr/sbin/nginx-test --modules-path=/usr/lib64/ringcentral/nginx-test/modules --conf-path=/etc/ringcentral/nginx-test/nginx-test.conf --error-log-path=/var/log/ringcentral/nginx-test/nginx-test-nginx_error.log --http-log-path=/var/log/ringcentral/nginx-test/nginx-test-nginx_access.log --pid-path=/var/run/ringcentral/nginx-test/nginx-test.pid --lock-path=/var/run/ringcentral/nginx-test/nginx-test.lock --http-client-body-temp-path=/var/cache/ringcentral/nginx-test/nginx-test/client_temp --http-proxy-temp-path=/var/cache/ringcentral/nginx-test/nginx-test/proxy_temp --http-fastcgi-temp-path=/var/cache/ringcentral/nginx-test/nginx-test/fastcgi_temp --http-uwsgi-temp-path=/var/cache/ringcentral/nginx-test/nginx-test/uwsgi_temp --http-scgi-temp-path=/var/cache/ringcentral/nginx-test/nginx-test/scgi_temp --user=peter --group=root --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-stream --add-module=/home/peter/git/rcv-nginx/build/rpmbuild/BUILD/nginx-test/ngx_devel_kit-0.3.0 --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --add-module=/home/peter/git/rcv-nginx/build/rpmbuild/BUILD/nginx-test/lua-nginx-module-0.10.11rc2 --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' --with-debug
How to Reproduce:
- Configure Nginx:
location /sub
{
error_page 502 @intercept_502;
set $remote_host "http://invalid_host";
proxy_pass $remote_host;
}
location /lua
{
content_by_lua_block
{
res = ngx.location.capture("/sub")
ngx.say(("Status: '%s';"):format(res.status));
ngx.say(("Body: '%s';"):format(res.body));
ngx.say(("Truncated: '%s';"):format(res.truncated));
}
}
location @intercept_502
{
default_type application/json;
return 500 '{ "error": "cannot proxy request (502: Bad Gateway)" }';
}
- Request
/sub - Request
/lua
Expected:
{
"error": "cannot proxy request (502: Bad Gateway)"
}
Status: '500';
Body: '{ "error": "cannot proxy request (502: Bad Gateway)" }';
Truncated: 'false';
Actual:
{
"error": "cannot proxy request (502: Bad Gateway)"
}
Status: '502';
Body: '';
Truncated: 'true';
Nginx Debug Logs:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ngx.location.capture() reproduction and the linked nginx-location-capture.log, using the provided /sub, /lua, and @intercept_502 configuration. Trace how the configured error_page response is handled during capture. Done means the capture returns status 500 with the expected response body and truncated set to false.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100