Currently i am using haproxy with manual updating backends which points to separate docker nginx containers for different apps.

What is best software to proxying request to different local nginx containers based on hostname?

I would have a simple map file or even /etc/hosts/ which my script would update when docker containers change, for example:

```
domain1 1.1.1.1
domain2 1.1.1.2
domain3 1.1.1.3

```

So ideal will be haproxy -> some software proxy or dns -> docker nginx

and software would use map file in fly, not reloading and point request to local ip address.

Maybe i would put varnish cache in front so it would need to be compatible with that too (and why wouldn't) so flow would be:

request -> haproxy (for load balancing in multiple servers)

-> varnish on public server ip ( for in memory caching based on host and route, so if there is cache return response immediately )

-> SOME PROXY OR DNS BASED ON SIMPLE MAP FILE which will further proxy to local ip of one of multiple docker nginx containers

-> docker nginx inside custom network

-> some app in container

What is best practice for this flow, should i put varnish somewhere else, and what is a software i am seeking for?

I am currently using one extra nginx and mapping $host to custom ip address in custom maps.conf file and gracefully reloading nginx on change, but i got feeling that there is better solution for this.

Also i forgot to mention that i dont need only http proxying based on map file, but tcp (ssh, smtp, ftp..) too, just in those cases i will not have haproxy and varnish in front and this app would be public faced on those port.

for example:

```
port:22
domain1 1.1.1.1
domain2 1.1.1.2
domain3 1.1.1.3

port:25 
domain1 1.1.1.4
domain2 1.1.1.5
domain3 1.1.1.6

```