Nginx Load Balancer Cluster

Source: Internet
Author: User
Tags nginx load balancing

Nginx Load Balancer Cluster

Nginx load balancing function In fact and Nginx proxy is the same function, just to the previous agent a machine to agent more than one machine, nginx load and compared to LVS, Nginx belongs to a more advanced application layer, not involved in IP and kernel changes, It simply forwards the user's request to the back of the machine, so the backend real server does not need to configure the public IP

First, configure the environment

Nginx Dispatcher (a public network 192.168.101.230 and an intranet IP192.168.104.230)

Rs1 Intranet IP (192.168.104.108)

RS2 Intranet IP (192.168.101.109)


Second, the specific configuration process

[Email protected] ~]# cd/usr/local/nginx/conf/vhosts/

[[email protected] vhosts]# ls

default.conf proxy.conf test.conf

[Email protected] vhosts]# vim lb.conf

Upstream Daixuan {

Ip_hash;

Server 192.168.104.108:80;

Server 192.168.104.109:80;

}


server {

Listen 80;

server_name www.daixuanlinux.com;

Location/{

Proxy_pass http://Daixuan/;

Proxy_set_header Host $host;

}

}


[Email protected] vhosts]#/etc/init.d/nginx restart

Stop nginx: [OK]

Starting nginx: [OK]

[Email protected] vhosts]# ipvsadm-c

[Email protected] vhosts]# iptables-t nat-f

[Email protected] vhosts]# iptables-f

[Email protected] vhosts]# NETSTAT-LNP

Active Internet connections (only servers)

Proto recv-q send-q Local address Foreign address Stat e pid/program name

TCP 0 0 0.0.0.0:3306 0.0.0.0:* LIST EN 2492/mysqld

TCP 0 0 0.0.0.0:80 0.0.0.0:* LIST EN 2947/nginx


Third, testing

[Email protected] vhosts]# curl-xlocalhost:80 www.123.com

Turns out rs1rs1 and RS2R2 switch

This article is from the "Daixuan" blog, make sure to keep this source http://daixuan.blog.51cto.com/5426657/1737460

Nginx Load Balancer Cluster

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.