仅做负载均衡 upstream 简单场景记录,更多策略与参数可查阅官方文档
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream

nginx.conf 片段

upstream example_nginx_lb {
    server 127.0.0.2:80;
    server 127.0.0.3:80;
}
server {
    listen 8080;
    location / {
        proxy_pass http://example_nginx_lb;
    }
}

解析

1.使用 upstream 配置负载均衡,通过轮训(默认轮训)负载到了 2 台机器的 80 端口
2.server 配置监听 listen 8080 端口请求,proxy_pass 代理到负载均衡器