Nginx load balancing and reverse proxy

Source: Internet
Author: User
Tags nginx load balancing

Nginx load Balancing

What is nginx load Balancing?

Nginx as a powerful Web Server management software, itself with load balancing and reverse proxy function, then What is the difference between him and LVs?

LVS Load: is based on 4 - tier load balancing,

Advantages:

1 strong resistance to load

2 Low Profile

3 Work Stability

4 No Flow

5 Basic support for all application load balancing, such as WEB, Database

Nginx Load: 7 - tier load Balancing

Characteristics:

1nginx works on the 7 layer of the network, he can do the distribution policy for HTTP itself, such as domain name, directory structure, etc.

2nginx is less dependent on the network

3 Easy To configure, easy to test

The 4nginx is also capable of withstanding high loads and stable

Nginx Application Scenario

load Balancing for 7 layers

Nginx Disadvantages:

1, Nginx can only support HTTP, HTTPS and email protocol, so in the scope of application smaller, this is its shortcomings.

2, the back-end server Health check, only support through the port to detect, not supported by the URL to detect. The direct hold of the session is not supported, but can be solved by Ip_hash.

Nginx Load Balancer configuration

Architecture

Load: 192.168.1.104

Web1:192.168.1.105

WEB2:192.168.1.106

Test whether the Web site is normal between two Web sites, and whether the server communicates

Ok All communication

Start configuring Load Nginx now

First add the hosts file to two other host files to ensure domain name communication

Ok to ensure domain name communication

Configuring the nginx.conf file

We said before. nginx load Balancing requires a module upstream

This module is used for load balancing.

Upstream Servers {

Server 192.168.1.105:80 weight=1;

Server 192.168.1.106:80 weight=1;

}

Nginx Reverse Proxy

Nginx Reverse Proxy In addition to the IP address forwarding, but also through the url extension forwarding and so on, follow up

Upstream Servers {

Server 192.168.1.105:80 weight=1;

Server 192.168.1.106:80 weight=1;

}

server {

Listen 80;

server_name www.xiaohu.com;

Location/{

Proxy_pass http://192.168.1.105; this refers to the address of the agent, the address must be in the upstream module to jump

root HTML;

Test

[Email protected] ~]# Curl www.xiaohu.com

192.168.1.105

Skip to


Nginx load balancing and reverse proxy

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.