Hello,
I have a configuration similar to this:
location /test/
{
rewrite_by_lua '
local orig_url = ngx.var.uri
local rand = math.random(100)
local to302 = rand <= 20
local ext1 = string.find(orig_url, ".jpg")
if to302 and ext1 then
ngx.log(ngx.ERR, "orig_url 302 ", orig_url)
return ngx.redirect(orig_url)
else
ngx.log(ngx.ERR, "orig_url no 302 ", orig_url)
end
';
proxy_pass http://127.0.0.1:8081;
}
What I want to achieve is that ~20% of the requests for *.jpg files to be routed to a different location.
It seems to work - I checked this by commenting out the line "proxy_pass http://127.0.0.1:8081;" and seeing that I only g some Images.
So I assume that requests that do not get to return ngx.redirect("http://127.0.0.1:8082") fall into proxy_pass.
Does this work the way I expect?
Thanks,
Alex