Nginx Doing load Balancing

Source: Internet
Author: User

A recent study of Nginx,nginx as a reverse proxy server provides acceleration to the Web server and features load balancing.

First of all, I want to download Nginx (http://nginx.org/en/download.html) on the official website, the latest version is 1.9.5, Linux and Windows versions I've been down, doing web load balancing on both servers.

In the version of Windows, unzip the package and execute the command:

Start Nginx

This will enable the Nginx service to start. and execute the command:
Nginx-s stop
You can stop the service.

Execute command

Nginx.exe-s Reload

You can reload the configuration file

I'm using a native test, this is my IIS server on 192.168.100.11, add two sites:

These two sites add two files index.html, two file contents respectively: "Port Bayi", "port82".

Configure the host file as follows:

192.168.100.11 test.com

In the nginx.conf configuration file, adjust the relevant configuration:

Upstream test.com{
Server 192.168.100.11:81;
Server 192.168.100.11:82;
}

Listen 80;
server_name 192.168.100.11;

#charset Koi8-r;

#access_log Logs/host.access.log Main;

Location/{
root HTML;
Index index.html index.htm;
Proxy_pass http://test.com;
}

Proxy_pass http://test.com; This test.com is the address of the domain name configured in the host file, corresponds to the file configuration in the host, and after the file is saved, executes the command

Nginx.exe-s Reload

When you open a browser test and refresh the page, you will switch back and forth between the two sites.

Open the configuration file and modify it as follows:

Upstream test.com{
Ip_hash;
Server 192.168.100.11:81;
Server 192.168.100.11:82;
}

Save, execute command

Nginx.exe-s Reload

In the next test, you will find that the refresh only on one site to access, you can solve the problem of the session.

Nginx Doing load Balancing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.