Docker Community Forums

Share and learn in the Docker community.

How to serve Docker containers with Nginx if there are multiple sites on one host?


(Isqua) #1

I have three web-apps on one server: two nodejs apps and one php. Now I don’t use containers, so the flow is following:

One Nginx is running. It select backend and static files dir by hostname. E.g. if I go to mysite.com it proxy requests to localhost:3000 and use static files from /sites/mysite/static. If I go to sistersite.com nginx proxy requests to PHP and use static files from /sites/sistersite.com and so on.

Now I want to isolate applications and try Docker. Should I include Nginx to each container and resolve hosts-to-container by some router or should I include only application and use common Nginx installed to the host machine? If second, how to return static files? By adding root /path/to/static/in/container? Sites also support both http and https, so they use different certificates.


(Sam Saffron) #2

For PHP you are stuck running NGINX anyway, so if you want to isolate you are going to need to bundle it AFAIK. Otherwise how are you going to isolate php version and so on.

Just place HAProxy either on the host or in a container to front it all and have it farm requests to the various sites, HAProxy is king at this kind of stuff.