How to perform an Nginx Load Balancing (polling) experiment on a PC

Source: Internet
Author: User
I. Before reading this article in the experiment environment, I assume that the reader has a good understanding of nginx installation and Virtual Machine installation, and does not detail these contents. The operating system of a pcpc is win7, and two linux virtual machines are used in vmware. The pc is connected to a switch with the IP address 192.168.1.100nginx version 1.05, where win7 is the Server Load balancer proxy machine,

I. experiment environment

Before reading this article, it is assumed that the reader has knowledge about nginx installation and Virtual Machine installation, and does not detail these contents.

One pc

The operating system installed on the pc is win7, and two linux virtual machines are used in vmware. The pc is connected to a switch with the IP address 192.168.1.100.

Nginx version 1.05, where win7 isServer Load balancerProxy machine. Virtual linux is a web server.

When configuring vmware, select "br" for "network connection ".IdGEdThe ip addresses of the two VMS are 192.168.1.102 and 192.168.1.103, respectively.

Ii. Configuration File

1. The nginx configuration file for Server Load balancer in win7 is as follows (nginx. conf). After modification, enter nginx-t on the console to test whether the modified configuration file is correct.

UpsTrEam test {

Server 192.168.1.102;

Server 192.168.1.103;

}

Server {

Listen 80;

Server_name localhost;

CharSetGbk;

# Access_log logs/host. access. log main;

LoCatIon /{

Proxy_nExT_upstream errorTimeOut invalid_header http_500

Http_502 http_503 http_504 http_404;

Proxy_connect_timeout 10 s;

Proxy_read_timeout 2 s;

# Proxy_send_timeout 10 s;

Proxy_pass http: // test;

}

2. The nginx configuration file used as the web server on linux can be used as the default and remains unchanged.

3. modify it to the nginx directory of the Web server, and set index.html in the HTML directory! I am server x !, This step is to determine whether the service is effective.

Iii. Running services

1. win7: Enter nginx on the console.

2. linux: nginx-c./conf/nginx. conf

If it runs successfully, enter http: // 192.168.1.100 in your win7 browser. Then, I am server 2 will be displayed. Press f5 to refresh the page and the server name will change every time!

Iv. Conclusion

This article is just a simple test of the Round-Robin trial load balancing on a machine.

All subsequent experiments will be tested on this machine.

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.