Question

How to setup nginx server blocks with docker containers?

  • Posted on November 29, 2014
  • viewplAsked by Rob Lao

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

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This question was answered by @ryanpq:

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.

View the original comment