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

NGINX load balancing settings and reverse proxy settings

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

NGINX Load Balancer Settings and Reverse Proxy Settings are brought to you below. I hope they can bring some help to you in practical application. Load Balancer involves many things, but there are not many theories. There are many books on the Internet. Today, we will use the accumulated experience in the industry to make an answer.

"1"NGINX Load Balancer Settings

(1) Polling algorithm: Assign the request sequence to different Cloud Virtual Machine each time. Through this algorithm, polling forwarding of requests among multiple machines can be realized.

upstream test_svr

{

server 192.168.1.10:8080;

server 192.168.1.20:8080;

server 192.168.1.30:8080;

}

In the NGINX configuration file, define a set of Load Balancer backend service pool areas with the upstream directive.

(2) Weight algorithm: By setting different weights for different backend servers to achieve proportional distribution of requests, the backend server can be automatically eliminated when it fails.

upstream test_svr

{

server 192.168.1.10:8080 weight=1 max_fails=1 fail_timeout=10s;

server 192.168.1.20:8080 weight=2 max_fails=1 fail_timeout=10s;

server 192.168.1.30:8080 weight=3 max_fails=1 fail_timeout=10s;

}

where test_svr is the server group name. weight sets the weight of the server, the default is 1, the higher the weight value, the more requests the server can receive. max_failures and fail_timeout indicate that NGINX will consider a server as failed if max_failures occurred within the fail_timeout period and eliminate the server.

(3) IP hash algorithm: This algorithm distributes requests to backend servers according to the client IP of the user. Since clients with the same source IP have the same value after IP hash algorithm, requests from the same client can be distributed to the same backend server. IP hash Load Balancer is primarily specified by the instruction ip_hash.

upstream test_svr

{

ip_hash;

server 192.168.1.10:8080;

server 192.168.1.20:8080;

server 192.168.1.30:8080;

}

"2"NGINX Reverse Proxy Settings

Reverse proxy mode is different from common proxy mode. Reverse proxy server can forward the request to real WEB server at the backend according to specified Load Balancer algorithm. Load Balancer and cache technology of proxy server can be combined together, so as to improve the access speed of static web page, so better Load Balancer can be realized.

"proxy_pass http://test_svr" specifies the server pool for the reverse proxy.

After reading the above about NGINX Load Balancer Settings and Reverse Proxy Settings, if you still have anything you need to know, you can find something you are interested in the industry information or find our professional technical engineers to answer. Technical engineers have 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