How to configure Nginx as a load balancer using the StrongLoop Nginx controller

I am trying to set up Nginx as a load balancer using the StrongLoop Nginx controller. Nginx will act as a load balancer for the StrongLoop LoopBack application hosted by the standalone StrongLoop process manager. However, I was unable to do the Nginx deployment following the official directions from StrongLoop. Here are the steps I took:

Step # 1 . My first step was to install Nginx and StrongLoop Nginx controller on my AWS EC2 instance. I ran EC2 sever (Ubuntu 14.04) to host the load balancer and connected to the Elastic IP server. Then I ran the following commands:

$ ssh -i ~/mykey.pem ubuntu@[nginx-ec2-ip-address]
$ sudo apt-get update
$ sudo apt-get install nginx
$ sudo apt-get install build-essential
$ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
$ sudo apt-get install -y nodejs
$ sudo npm install -g strong-nginx-controller 
$ sudo sl-nginx-ctl-install -c 444

      

Then I opened port 444 in the security group of the EC2 instance using a custom TCP rule.

Step # 2 . My second step was to set up two Loopback Application Servers. To do this, I started two more EC2 servers (both Ubuntu 14.04) for application servers, and connected to each Elastic IP server. I then ran the following sequence of commands once on each application server:

$ ssh -i ~/mykey.pem ubuntu@[application-server-ec2-ip-address]
$ sudo apt-get update
$ sudo apt-get install build-essential
$ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
$ sudo apt-get install -y nodejs
$ sudo npm install -g strong-pm
$ sudo sl-pm-install
$ sudo /sbin/initctl start strong-pm

      

Step # 3 . My third step was to deploy the application to each of the application servers. For this I used StrongLoop Arc:

$ cd /path/to/loopback-getting-started-intermediate # my application
$ slc arc

      

Once in the StrongLoop Arc web console, I created a tar for the application and deployed it to both application servers. Then in Arc Process Manager, I connected to both application servers. Once connected, I clicked on "load balancer" and entered the Nginx host and port into the form and clicked save. This caused a pop-up message stating that the load balancing configuration was saved.

At this point, something strange happened: the fields in StrongLoop Arc, where I had just typed the load balancing settings (host and port), reverted to the original values ​​that the fields had before I started typing. (The original port was 555, and the original host was the address of my second application server.)

I don't know what to do next . Here I really don't know what to do next. (I tried to open my web browser and navigate to the IP address of the Nginx load balancer using several different port values. I tried 80, 8080, 3001, and 80, opening each of the security group, trying to find the location I need to navigate to. to see "load balancing" in action. However, I didn't see anything navigating through each of these locations, except for port 80, which served the "welcome to Nginx page" not what I'm looking for.)

How do I configure Nginx as a load balancer using the StrongLoop Nginx controller? What is the next step in this process if all my steps are listed correctly.

+3


source to share


1 answer


I usually do the following:

sudo sl-nginx-ctl-install -c http://0.0.0.0:444

      



Perhaps this can solve your problem.

0


source







All Articles