负载的地址:
upstream test{
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server {
location / {
proxy_pass http://test;
}
}
负载均衡策略:
Nginx 提供轮询(round robin)、用户 IP 哈希(client IP)和指定权重 3 种方式。
upstream test{
ip_hash;
server backend1.example.com;
server backend2.example.com;
server.backend3.example.com;
}
upstream test{
server blog.csdn.net/poechant down;
server 145.223.156.89:8090;
server unix:/tmp/backend3;
}
upstream test {
server backend1.example.com;
server 123.321.123.321:456 weight=4;
}