Reputation: 43
Just started implementing docker containers, I'm not sure if it is possible or not yet. Is it possible to publish a docker container based on URL or at specific host header? For example, two containers running at port 192.168.1.2 and port 80 but the first container has website abc.com and the second container has website xyz.com.
Can we use some reverse proxy server e.g. NGINX (or any other that you suggest) to direct web request to respective docker container?
Upvotes: 1
Views: 6026
Reputation: 9111
No, you can't have "two containers running at IP 192.168.1.2 and port 80", but you can have a reverse-proxy running at IP 192.168.1.2 and port 80 and route to containers running at different IP+port.
Upvotes: 2
Reputation: 5454
If you want to generate nginx configuration dynamically when you start/stop docker containers, you can consider using jwilder/nginx-proxy project. This will give you more flexibility when deciding your domains.
Upvotes: 0
Reputation: 596
Yes, you could do that, you can run a nginx container (or in the host) and it will redirect the content to the right container using the requested server name.
You can map the nginx 80 port in the nginx container to the host and link the others containers to it and then configurate nginx to do the proxy.
Here is a post about how to do it:
http://www.yannmoisan.com/docker.html
Upvotes: 0