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

How to configure proxy and realize load balancing in nginx

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

In this issue, the editor will bring you about how to configure agents and achieve load balancing in nginx. The article is rich and analyzed and described from a professional point of view. I hope you can get something after reading this article.

What if we only have one server and need to use the same port such as 80?

Some bosses say they can be put under the same tomcat, so if I have 10 projects, 50 projects, you maintain a tomcat?

two。 Load balancing

There is no need to say much about this concept, mainly to achieve high availability.

3. Current limit

This ng is only the first stream limit of the hardware. The token bucket method is used to limit the current of the program, such as the limit of java's gava package. Mainly to prevent avalanches.

3. Web caching

Many browsers now cache automatically without turning off the uncleared cache once. Previous versions required ng control.

4. Compress

Image upload and download in order to speed up the efficiency of the use of compression unified processing.

Actual combat

Worker_processes 1; events {worker_connections 500;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server {listen 80; server_name localhost; root D:/root # forward location / wechat {proxy_pass http://127.0.0.1:8080/sms;}

As shown in the figure, we have configured location, and the user accesses port 80 by default. If the user enters localhost/wechat, then we forward it to the http://127.0.0.1:8080/sms sms project.

Load balancing

Worker_processes 1; events {worker_connections 500;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # load balancer setting variable upstream local {server 127.0.0.1 worker_connections 8030 weight=10; server 127.0.0.1 worker_connections 8040 weight=10; server 127.0.0.1 worker_connections 8050 weight=10 Server 127.0.0.1 weight=10; 8060 weight=10;} server {listen 80; server_name localhost; root D virtual http://local/sms;; # forward location / wechat {proxy_pass Root } the above is how to configure proxies and achieve load balancing in nginx shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report