Report this

What is the reason for this report?

How to setup nginx server blocks with docker containers?

Posted on November 29, 2014

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



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!

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.

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.