search

Home  >  Q&A  >  body text

openresty - Use lua-nginx-module to modify the content in upstream and reload

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.

阿神阿神2744 days ago705

reply all(2)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:12:36

    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.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-16 17:12:36

    Do you want to implement a function similar to dynamic load? If so, I think you can use openrestyngx.balancer来解决。这样无需重启nginx to dynamically change the backend server.

    reply
    0
  • Cancelreply