Use multiple dockerized Nginx behind a host Nginx
Solution 1:
-
Is it ok to use Nginx in the host which will forward traffic to multiple different dockerized Nginx?
Yup, it's actually a common practice.
-
Does it have any known problems?
Caused by this setup itself - nope.
-
Will that affect performance?
In a way - sure: like every other load balancer (which it is) it will add some delay on buffering and TCP sockets.
Solution 2:
-
Is it ok to use Nginx in the host which will forward traffic to multiple different dockerized Nginx?
Yes. This is one way to do it.
-
Does it have any known problems?
The host instance of NGINX is not containerised which may make it more difficult to configure. Another common way to do this is to have a docker container bound to port
80
and443
which handles all ingress traffic and diverts it to the corresponding container.Finally, other container orchestration systems like Kubernetes have the concept of
Ingress
built in and allow it to be configured just like you'd configure a container in Docker compose. The upside to Kubernetes Ingress is that it can scale up/down to multiple servers whereas you are more limited with Docker compose. -
Will that affect performance?
Having an extra hop to get to the destination container does negatively harm performance but its a common thing to do.