I have a swarm on multiple nodes, each of the nodes has its own URL address.
Each of the nodes can return 301 to a different node URL (external URL) in some cases.
I want to make sure that a node doesn't redirect a client to a node that is down.
I thought maybe to add an environment variable to the swarm and in it set all the live nodes, and when some node is down than to automatically reset the environment variable to the new value.
for example, I have: www.a.com (node a), www.b.com (node b), www.c.com (node c).
when they are all up, the environment is set to (www.a.com,www.b.com,www.c.com), when b for example is down then it will change to (www.a.com,www.c.com).
Now the questions I have is: A. How can I do that? How can I make the swarm update an environment variable base on the nodes that are up? B. How can I make the dockers in the node know that they need to reload the environment variable? (I don't want to read it every x seconds, I think its too expensive)