nginxwebservermultiple-instances

Nginx multiple instances


I have an EC2 instance with AWS and I have installed nginx and created multiple server blocks to server multiple applications.

However, if nginx goes down, all the applications go down as well.

Is there any way to setup seperate nginx instance for each application? So if one nginx instance goes down, it won't affect other instances.


Solution

  • Yes, its technically possible to install 2 nginx instances on the same server but I would do it another way.

    1 - You could just create multiple EC2 instances. The downside of this approach is that maybe it's gets harder to maintain depending on how many instances you want.

    2 - You could use Docker or any of its alternatives to create containers and solve this problem. You can create as many containers you need and totally separate nginx instances. Although docker is simple to learn and start using it in no time, the downside of this approach is that you need to put a little effort to learn it and your main EC2 instance needs to have enough resources to share between the containers.

    I hope it helps!