Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The frame structure of nginx load balancing

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following brings you the framework of nginx load balancing, hoping to give you some help in practical application. Load balancing involves many things, and there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

Frame structure

192.168.178.131 load balancing

192.168.178.130 web01

192.168.178.129 web02

The same nginx version is installed on all three CVMs.

The configuration of 192.168.178.131 is added

Upstream test.miaohr.com {- # test.miaohr.com this must be consistent with the following proxy_pass. Below is the weight pattern load.

Server 192.168.178.129:80 weight=80

Server 192.168.178.130:80 weight=10

}

Server {

Listen 80

Server_name test.miaohr.com

# charset koi8-r

# access_log logs/host.access.log main

Location / {

Root html

Index index.html index.htm

Proxy_pass http://test.miaohr.com;

Proxy_set_header X-Real-IP $remote_addr

Client_max_body_size 100m

}

192.168.178.130 web01 and web02 only need to configure the domain name host

Server {

Listen 80

Server_name test.miaohr.com

# charset koi8-r

# access_log logs/host.access.log main

Location / {

Root html

Index index.html index.htm

}

1, weighted load pattern

-# test.miaohr.com this must be consistent with the following proxy_pass. Below is the weight mode load.

Upstream test.miaohr.com {

Percentage of access probability of server 192.168.178.129 weight=80; weight as background server

Server 192.168.178.130:80 weight=10

}

2 polling mode

-# test.miaohr.com this must be consistent with the following proxy_pass. Next is the polling session at 1:1 to access the back-end server.

Upstream test.miaohr.com {

Server 192.168.178.129:80

Server 192.168.178.130:80

}

3 、 ip_hash

Each request is allocated according to the hash result of accessing the ip, so that each visitor accesses a back-end server on a regular basis, which can solve the session problem.

Upstream test.miaohr.com {- # test.miaohr.com this must be consistent with the following proxy_pass. The following is the polling session at 1:1 to access the back-end server.

Upstream test.miaohr.com {

Ip_hash

Server 192.168.178.129:80

Server 192.168.178.130:80

}

Test binding vhost load balancer ip 192.168.178.131 test.miaohr.com

Create a test.html file with different contents in the test.miaohr.com directory under web01 and web02

The information of visiting test.miaohr.com/test.html page is different.

After reading the above framework of nginx load balancing, if you have anything else you need to know, you can find out what you are interested in in the industry information or find our professional technical engineer to answer, the technical engineer has more than ten years of experience in the industry.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report