HA with nginx and cloud environment
-
25-09-2019 - |
Question
I have a node in cloud environment which is used now as nginx and mongrels behind it.
This is what nginx config looks like:
upstream mongrel {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
}
I want to achieve the following:
- add another node
- nginx has to know about this new node automatically without stopping him, changing config(manually adding new node's mongrels) and starting it again.
How can I make my load balancer(nginx) work in the way so it can be self-aware of nodes in cloud?
Solution
Create a script which writes the config file for you.
You can write a template config file where you replace the stuff you want to include automatically with some sort of placeholder, then you use a script which fetches your node list (from a database or something), creates the final config file and reloads the config in Ngnix.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow