Question
How to setup nginx server blocks with docker containers?
Hi,
I read following article about setup nginx virtual hosts.
https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts
However, I require a bit further. If I have multiple docker containers with one website hosted in each, how to do that with nginx? Is there a tutorial about how to do this?
Thanks
Rob L
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
What I would recommend is to set up your individual containers with their services listening on different ports and then use proxy_pass to proxy connections to the correct service. Since you could not have a web service in two different docker containers both listening on port 80 (at least publicly) you can use nginx to translate server blocks to ports either on the public network or the internal one used by docker.