Step 1 – Install Nginx Server
First of all, Login to your server with SSH access. Windows users can use PuTTY or alternatives to SSH into the server. Now install Nginx using Linux package manager. Nginx package is available under default yum and apt repositories. Using Apt-get: Using Yum: Using DNF:
Step 2 – Setup VirtualHost with Upstream
Let’s create a Nginx virtual host configuration file for your domain. Below is my minimal settings configuration file. /etc/nginx/conf.d/www.example.com.conf
Step 3 – Other Useful Directives
You may also use some more useful settings to more customize and optimize your load balancer with Nginx. For example set, the weight and IP hash like below with configuration.
Weight
IP Hash
Step 4 – Restart Nginx Service
After making all the changes, restart Nginx service with the following command.