Nginx – How to run multiple NGINX instances for servers to be developed together but deployed separately

cachenginxreverse-proxyUbuntuvideo streaming

I'm an NGINX beginner who is building both an adaptive live video server (HLS & DASH) and a caching HTTPS reverse proxy server.

While the servers will be deployed to separate boxes, I'd like to develop both on the same box so I can tune them in the same environment, so I can more easily observe the traffic and resource trade-off between them. This process will also help determine and balance the hardware resources needed by each of the deployment boxes.

What's the best way to do this? (Under Ubuntu 18.04, in my case.) Should I create separate services, or just run one as a service and one as a regular process? Any problems I should anticipate?

Best Answer

Nginx comprises multiple worker processes and one master process to watch after them all. It's configuration consists of multiple virtual hosts configurations each under the server {} clause, which may have different options. They usually run serving the same network socket. This all together is highly configurable and very comfortable to manage. On the other hand, multiple-instance nginx installation is cumbersome and unclear, even being still possible.

Considering all of the above, I see no point of running multiple instances of nginx on one server, since you will have multiple workers anyway (if you will set their number greater than one). When you will dispatch them on different boxes you will simply split their virtual hosts configs and tune the main config using the "what fits best" approach.