How to set up load balancing in nginx
In view of how to set up load balancing in nginx, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
1 、
User nobody;worker_processes 4 events {worker_connections 1024;} http {upstream mypro {server 182.13.32.12; server 213.11.23.24;} server {listen 8080; location / {proxy_pass http://mypro;}
2. Join ip_hash to make the same user fall on the same machine.
Use nobody;worker_processes 4 events {worker_connections 1024;} http {upstream mypro {ip_hash; server 182.13.32.12; server 213.11.23.24;} server {listen 8080; location / {proxy_pass http://mypro;}
3. Add weight
Use nobody;worker_processes 4 the number of cores of events {worker_connections 1024;} http {upstream mypro {server 182.13.32.12 weight=2;// access probability server 213.11.23.24;} server {listen 8080; location / {proxy_pass http://mypro; } the answer to the question on how to set load balancer in nginx is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more relevant knowledge.