Open olegabr opened 7 years ago
@olegabr I guess that image filter module just refuses to work in the context of a subrequest.
lua-resty-http wins, as always. may be it should be included in the core bundle? in a docker image at least?
location /test3/ {
content_by_lua_block {
local url = "http://127.0.0.1/ttt/"
local http = require "resty.http"
local httpc = http.new()
local res, err = httpc:request_uri(url)
if not res then
ngx.say("failed to request: ", err)
return
end
ngx.status = res.status
ngx.say(res.status)
ngx.say(res.body)
}
}
@olegabr subrequests do not incur any TCP (loopback) or socket overhead, unlike the http call in your example. In this particular case, I think it is much more efficient if you call libgd via FFI directly.
@olegabr Maybe your issue is related to Lua, memc and image_filter, image not resized via lua
This is because the standard ngx_image_filter module's output filter always runs after ngx_lua's subrequest capturing filter and there's no easy way to change this order. The response body of your subrequest is captured by ngx_lua before the ngx_image_filter's filter gets a chance to run.
@agentzh thank you for the suggestion. I'll take it into account on an optimization phase.
I'm trying to get image width and height information. I can do it directly by querying the proxied location with curl, but I can not do it from lua code with ngx.location.capture. it just returns the image without
image_filter
processing:The config
Direct call: success
Indirect call: failure
Can you please point me how to make it work from
ngx.location.capture
?