curl localhost 访问接口
配置1:res.body获取的是压缩数据
location / {
content_by_lua_block {
local res = ngx.location.capture('/sub')
do_something(res.body)
}
}
location /sub {
gunzip on;
proxy_set_header Accept-Encoding gzip;
proxy_pass https://www.baidu.com/;
}
按逻辑res.body应该是gunzip解压后数据,ngx.location.capture不能捕获的指令也不包括gunzip,不知道为何gunzip根本没运行?
配置2:res.body获取的是解压数据
location / {
content_by_lua_block {
local res = ngx.location.capture('/sub')
do_something(res.body)
}
}
location /sub {
proxy_pass http://localhost/sub1;
}
location /sub1 {
gunzip on;
proxy_set_header Accept-Encoding gzip;
proxy_pass https://www.baidu.com/;
}