Nginx – DNS Reverse Proxy

Apache2dockerhaproxynginxreverse-proxy

I'm using Docker to deploy lots of micro services behind a reverse proxy. I would like to load balance my micro services based on DNS queries and also allow for automated failover and rebalancing once the proxy has started up.

I'm looking for a proxy server which supports load balancing between the returned servers from a DNS query. So for example test.local returns servers 192.168.1.1, 192.168.1.2, 192.168.1.3 and I would like to load balance traffic between them and do some standard reverse proxy rerouting stuff.

Nginx does the DNS query at startup but doesn't do the DNS query periodically and honour the TTL unless you have the Nginx Plus, which is expensive. If I restart my proxy periodically as the servers change then it might work but that would throw bad requests and wouldn't be a good solution.

I've looked to see if this can be done with Apache but I've not found anything.

Any help setting this up would be greatly appreciated as it's the last piece of the puzzle I need to get my servers fault tolerant.

Best Answer

You have clearly reached a level of complexity that you won't be able to handle using plain docker any more.

At this point you need to start using a higher level abstraction tool to manage your resources. The obvious choices are:

You don't provide enough details about the underlying platform that would help in choosing one over the other. My personal preference is Kubernetes, because I can abstract from pretty much any platform, and I can abstract even further to provide higher level capabilities using OpenShift or Tectonic.

Kubernetes operates on containers using the pod as the minimum abstraction unit. This allows a Kubernetes cluster to orchestrate and direct traffic to pods based on different probes.

In practice, this means you can perform deployments of new containers without downtime, have Kubernetes create new containers should the probe return failure, and even rollback the deployment (blue/green strategy).

This barely scratches the surface of what Kubernetes can do. If you are interested, the project has a very good documentation.

Related Topic