Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

35.6. upstream 负载均衡

		
http {
	upstream myapp1 {
		server srv1.example.com;
		server srv2.example.com;
		server srv3.example.com;
	}

	server {
		listen 80;
		location / {
			proxy_pass http://myapp1;
		}
	}
}
		
	

35.6.1. weight 权重配置

			
	upstream myapp1 {
		server srv1.example.com weight=3;
		server srv2.example.com;
		server srv3.example.com;
	}
			
		

35.6.2. backup 实现热备

			
	upstream backend {
		server backend1.example.com weight=5;
		server backend2.example.com:8080;
		server unix:/tmp/backend3;

		server backup1.example.com:8080 backup;
		server backup2.example.com:8080 backup;
	}

	server {
		location / {
			proxy_pass http://backend;
		}
	}