Hi:
i found a bug of using limit-rate, slice and bodyfilter_by_lua. i tried to figure it out but it didn't work.
i work on nginx-1.10.1 with lua-nginx-module-0.10.5. my nginx.conf is like below:
events {
}
worker_rlimit_nofile 30000;
error_log logs/error.log error;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#server_tokens off;
#etag off;
keepalive_timeout 30;
client_body_timeout 10s;
client_body_buffer_size 2M;
proxy_cache_path /tmp/nginx/cache levels=1:2 keys_zone=cache:100m;
server {
listen 8087;
server_name localhost;
location / {
limit_rate 1000k;
rewrite_by_lua_block {
ngx.header["xxxxx"] = "xxxx"
}
slice 100k;
proxy_cache cache;
proxy_cache_valid 200 206 60m;
proxy_cache_key $uri$is_args$args$slice_range;
#proxy_cache_key $uri$is_args$args;
proxy_set_header Range $slice_range;
body_filter_by_lua_block {
ngx.log(ngx.ERR, "1")
}
}
}
}
under the condition of missing local file( it is necesary too, the problem ocurs when it upstream to remote), i issue a request (
curl -vo /dev/null "http://127.0.0.1:8087/abc) to local server, it is normal at the beginning, but the speed will be shut down in serveral seconds. the speed will be slowed down to 0 kb/s, and the connection keep forever( i'd tried one day ). i found that i can make it normal through modifying nginx.conf:
1、it is normal after i modified limit_rate down below 100k. i found that faster the limit-rate is, sooner the request stop.
2、it is normal after i delete body_filter_by_lua_block in nginx.conf.
3、also, shutdown the slice cmd, it will be normal too.
i checked out error-log and i found that function "ngx_http_lua_body_filter" ran twice in one loop of body_filter when limit-rate, slice and bodyfilter_by_lua_block were all on. logs is shown down below:
![]()
after i deleted bodyfilter_by_lua_block, it would be normal:
![]()
Thanks!