proxy request to all backend servers

logar.damir nginx-forum at nginx.us
Fri Aug 26 08:10:09 UTC 2011


You should look at HttpLuaModule: 
http://wiki.nginx.org/HttpLuaModule#ngx.location.capture_multi

Example:
-- construct the requests table
    local reqs = {}
    table.insert(reqs, { "/mysql" })
    table.insert(reqs, { "/postgres" })
    table.insert(reqs, { "/redis" })
    table.insert(reqs, { "/memcached" })
 
    -- issue all the requests at once and wait until they all return
    local resps = { ngx.location.capture_multi(reqs) }
 
    -- loop over the responses table
    for i, resp in ipairs(resps) do
        -- process the response table "resp"
    end

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,213808,214322#msg-214322



More information about the nginx mailing list