当前位置: 首页 > Linux > 正文

How to Setup Load Balancing with Nginx in Linux

Prerequisites

You must have root access or sudo access to your server. Connect your server console with privileged access. Configure your site on backend servers.

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.

本文固定链接: http://t.yjsec.com/index.php/2017/12/02/12/ | 下一站

该日志由 admin 于2017年12月02日发表在 Linux 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: How to Setup Load Balancing with Nginx in Linux | 下一站
关键字:

How to Setup Load Balancing with Nginx in Linux:等您坐沙发呢!

发表评论

快捷键:Ctrl+Enter