Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to configure proxy and realize load balancing in nginx

Shulou Source: shulou.com Published: 2022-06-02 10:26:45 10月04日 Update

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.

Tags: Balance configuration cache project agent content user port analysis professional small and medium token rich content variable just only picture actual combat that is what to do Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Apple Shulou Information MySQL macOS