In this post I am going to present you, how to install NGINX and setup it to operate with simple HTTP routing.
Below are the two easy steps to install NGINX in your ubuntu system.
Once you are done go to any web browser and type in "http://localhost", in case you are installing in the local machine or "http://[IP_ADDRESS]"
This will show you the default HTTP page hosted by NGINX
Below are few easy commands to "Stop", "Start" or "Restart"
By now you have NGINX installed, up and running on your system.
We will next we how to configure NGINX to listen to a particular port and route the traffic to some other end points.
Below is a sample configuration file you need to create. Let's first see what each of these configuration means.
"upstream" : represents a group of endpoints that you need to route you requests.
"upstream/server" : an endpoint that you need to route you requests.
"server" : represent the configurations for listing ports and routing locations
"server/listen" : this is the port that NGINX will listen to
"server/server_name" : the server name this machine (where you install the NGINX)
"server/location/proxy_pass" : the group name of the back end servers you need to route your requests to.
The above configuration instructs NGINX to route requests that is coming into "192.168.58.123:8280", to be routed into "192.168.58.118:8280" or "192.168.88.119:8280" in round robin manner.
1. To make that happen you have to create a file with above configuration at "/etc/nginx/sites-available/mysite1". You can use any name you want. In this example I named it as "mysite1".
2. Now you have to enable this configuration by creating a symbolic link to the above file in "/etc/nginx/sites-enabled/" location
/etc/nginx/sites-enabled/mysite1 -> /etc/nginx/sites-available/mysite1
3. Now the last step. You have to restart the NGINX to get the new configurations affected.
Once restarted, any request you send to "192.168.58.123:8280" will be load balanced in to "192.168.58.118:8280" or "192.168.88.119:8280" in round robin manner.
Hope this helps you to quickly setup NGINX for you simple routing requirements