<p>Given a traditional Linux server ie- Ubuntu on a VPS</p>
<p>and a commercial app that requires a handful of Docker containers each of which need to communciate to one another ...</p>
<p>with one of those containers needing to serve port 80/443 on a public www domain...</p>
<p>is it better to setup an OS level Nginx that can sit outside the docker ecoysystem and simply proxy traffic to the single 'server' container?  (ie- install at OS level: nginx, docker and docker-compose)</p>
<p>or would it be better to instead put an Nginx image in each of the containers that need it?  (ie- install at OS level only docker and docker-compose; Nginx installed only inside containers)</p>
<p>by 'better' I am leaving that open to interpretation but definitely leaning to simpler configuration &amp; ease of operation, noting that said commercial app needs of course a convenient way to switch to a different set of env vars for local dev, staging and prod. Extra points for a tidy way to also handle secrets, git, and Dockerhub based continuous deployment.</p>

CC BY-SA 4.0
2021-07-27T03:30:21.023Z
thinking on this further I realized a more common setup is a single nginx docker container alongside your other containers or one of your containers includes nginx inside of it amongst say a web app that listens on port 80; vs ie- multiple containers each running an instance of nginx.
Derrick
CC BY-SA 4.0
2021-07-27T03:31:22.737Z
And at this point I assume the main reason to dockerify nginx vs installing it at root is simply the ability to easily pass in diff ENV vars depending on if you are running in dev, stage or prod.   Though you could also have a root OS install nginx and symlink your .conf configs to it via docker volumes, so I am not yet convinced why nginx needs to be containerized in the context of a Linux VPS in whereby the install/setup of nginx is only a one-liner anyway.
Derrick
<docker><docker-compose><nginx>
OS level Nginx that proxies to Dockers vs Dockers that each contain their own Nginx
Derrick
# OS level Nginx that proxies to Dockers vs Dockers that each contain their own Nginx

(Asked by: username_0 on 2021-07-26)

Given a traditional Linux server ie- Ubuntu on a VPS

and a commercial app that requires a handful of Docker containers each of which need to communciate to one another ...

with one of those containers needing to serve port 80/443 on a public www domain...

is it better to setup an OS level Nginx that can sit outside the docker ecoysystem and simply proxy traffic to the single 'server' container? (ie- install at OS level: nginx, docker and docker-compose)

or would it be better to instead put an Nginx image in each of the containers that need it? (ie- install at OS level only docker and docker-compose; Nginx installed only inside containers)

by 'better' I am leaving that open to interpretation but definitely leaning to simpler configuration & ease of operation, noting that said commercial app needs of course a convenient way to switch to a different set of env vars for local dev, staging and prod. Extra points for a tidy way to also handle secrets, git, and Dockerhub based continuous deployment.

**Tags:** docker, docker-compose, nginx

> **Comments:**
> **username_0**: thinking on this further I realized a more common setup is a single nginx docker container alongside your other containers or one of your containers includes nginx inside of it amongst say a web app that listens on port 80; vs ie- multiple containers each running an instance of nginx.  
> **username_0**: And at this point I assume the main reason to dockerify nginx vs installing it at root is simply the ability to easily pass in diff ENV vars depending on if you are running in dev, stage or prod.   Though you could also have a root OS install nginx and symlink your .conf configs to it via docker volumes, so I am not yet convinced why nginx needs to be containerized in the context of a Linux VPS in whereby the install/setup of nginx is only a one-liner anyway.  

---

## 0 answers

