I have one dev/Experimental server in our company, base of our projects is mainly java web apps, so when I want it to move our projects to Docker and scale horizontally to test our stateless servers, I did create docker-compose for each project with their own Nginx load balancer. As a result, I end up with 6 scalable projects and each with one Nginx, so I attached all Nginx to a same network and created main Nginx that attaches to port 80 of host and balance between all the running Nginx.
Problem: I was facing an issue with defined upstream as it was requiring the service to be up and sometimes some of projects were under maintenance and causing Nginx to crash.
Solution: adding seperate Nginx behind my main Nginx helped to run each project whenever I want and use only variable names in Nginx proxy pass so in case of upstream for any java project is down I still be able to run main Nginx.
Each nginx has block of
upstream mydocker-service{
...
}
and main Nginx contains multiple
set $stream mydocker-service;
used as proxy_pass.
at the end I end up with 6 Nginx responsible for upstream of each project and main Nginx responsible for redirecting request to each Nginx as proxy_pass.
Our projects are not Spring and is not possible to move to Spring either.
So my question is , this consider as a bad practice , am I doing it a right way? I there any better solution I can use without going overhead and do kubernetes as I only have one instance?