Can you provide some ideas? For example, I have the following upstream block in nginx.conf:
upstream value{
server 127.0.0.1:1234;
server 127.0.0.1:5678;
}
nginx provides external interfaces, such as 127.0.0.1/change, you can clear the contents of the above upstream, and reload all back-end server information from redis and write it to the above upstream in the nginx.conf file. Finally execute ./nginx -s reload.
Check whether lua has a file module that can operate on files, and also see if lua can call a shell or similar nginx signal to reload the nginx configuration file.
Do you want to implement a function similar to dynamic load? If so, I think you can use
openresty
的ngx.balancer
来解决。这样无需重启nginx
to dynamically change the backend server.