cdn-up-and-running icon indicating copy to clipboard operation
cdn-up-and-running copied to clipboard

How to add multiple host dynamic by lua code.

Open mdsohelmia opened this issue 2 years ago • 1 comments

mdsohelmia avatar Aug 03 '22 19:08 mdsohelmia

I don't know if I got you right, but you can use Lua to add dynamically hosts using https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md . There is in even a consistent hashing implementation https://github.com/openresty/lua-resty-balancer

You can update a shared list of dynamic hosts by having a background Lua task polling the hosts/ips you need to use. You'll need to pay attention to how you deal with health check as well.

BEWARE on how nginx/lua resolves name.

leandromoreira avatar Aug 04 '22 11:08 leandromoreira