参考这里:http://nginx.org/en/docs/http/load_balancing.html
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://myapp1;
}
}
}
完了。就是这么简单,更详细的请看>>这里<<
补充
1 srv1.example.com是个域名,可以写到host中,也可以直接写IP
2 myapp1就是个名字,随便写。
说明
1 负载均衡分为4层和7层,详细看>>这里<<
2 DNS是一种4层负载均衡方式,看>>这里<<
3 DNS负载均衡的例子在>>这里<<
4 nginx是7层负载
5 nginx有多种策略可选,看>>这里<<