Multiple public IP addresses to one Nginx?

1.2k views Asked by At

I am running multiple instance of MySQL using docker. I was planing to use nginx as reverse proxy server, I want assign public IP to each instance so I can map public ip to my docker networking,is this possible ?

2

There are 2 answers

1
Eugen Mayer On BEST ANSWER

You might want to use consul with registry part, since Consul offers you a DNS server for all registered instances : https://www.consul.io/docs/agent/dns.html

More or less that means, the docker instances register with consul, and consul can resolve them also for extern services. This will though required you to have more then one public IP.

If you want only one public ip, you obviously want to load balance mysql, since TCP connections cannot be "routed" by path / domain. That said, you can use consul as service-discovery and tiller+consul backend to generate you nginx configuration for the upstream, listing all the current available servers

1
Hamza Zafar On

You can simply use the reserved IPs from your private address space for docker containers, make your nginx instance routable from the internet by setting the public ip, finally you can load balance requests to your docker containers.