Nginx forward to multiple containers

I have read @simos 's guide on Digital Ocean to setup multiple containers as app servers. (Link : )
I also read a flockport guide on using nginx to forward traffic from the host to multiple containers which was what I was after. (Link : )

My focus is to serve the same website from both containers without the and initials.

I am a little perplexed with how it works though.
Flockport says, “First port forward the public IP port 80 to the Nginx container port 80. Now you can configure the Nginx instance to serve WordPress, Drupal and Joomla containers as a reverse proxy.”

Does this mean that ContainerA and ContainerB would both have to have a port forward rule from the host at port 80 using iptables ?
And then nginx can be setup on the host to distribute the incoming traffic using :

upstream xyz {

Pardon the long post. Trying to Learn the ins and outs of the system. Thank you for your time. :slight_smile:


It is not clear to me what you mean in this quoted paragraph.
Specifically, you are describing here something like load-balancing while the tutorials are about splitting websites into their own separate container.
That is, you have and, and you can set up each in their own separate LXD container.

With containers, you would have many websites on a single server. It is the reverse-proxy that does the disambiguation and routes the correct Web traffic to each container.
You can use nginx as the reverse-proxy, or you can use HAProxy.

In either reverse-proxy, you specify rules as in

  1. if the connection is for, then forward to container web_xyzcom.
  2. if the connection is for, then forward to container web_blogxyzcom.

The example that you give with nginx with upstream and the two IP addresses, is about setting up a load-balancing rule.

Thank you for the reply !

Yes I understand that now. MY main goal was to split traffic across to different containers.
I apologize but i posted the topic without banging my head a little. (laugh?)

My understanding was flawed in thinking that every time we defined a server in the upstream rule we were supposed to define a subdomain for the website.
I threw in a small experiment and connected my domain to my host.
Next i configured the containers in the upstream rule and viola I was able to split the traffic across.

PS : No need for iptables ! :relieved: :smile: