Upstream with zone directive

Sergey Kandaurov pluknet at
Wed Sep 19 11:35:42 UTC 2018

> On 17 Sep 2018, at 16:05, Johan Ekenlycka <johan.ekenlycka at> wrote:
> Hi!
> I am using ngx_lua_upstream module in OpenResty, which is calling ngx_http_get_module_main_conf(r, ngx_http_upstream_module). For some reason, I think the peer data is not correct when the zone directive is used in an upstream. But I am not really sure where in the source the config is parsed and peer/server data is populated.
> Can someone please get me some pointers to where I should look or even better if somebody could reaffirm and check the problem.

The ngx_lua_upstream module is not adapted to work with peers stored
in memory as a linked list, thus it cannot be used with upstream zone
that copies peers from configuration to shared memory one by one, thus
the peers' layout is effectively changed from an array to a linked list.
The problem you observe is that lua iterates peers by index as an array.

See this change as a guidance:

Sergey Kandaurov

More information about the nginx-devel mailing list