xd

xd

nginx实现负载均衡

参考官网:

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;
        }
    }
}

例如:
http {
    upstream myapp1 {
        server localhost:8091;
        server localhost:8092;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://myapp1;
        }
    }
}

这样,在浏览器输入http://localhost/hello,即可分发到localhost:8091/hello或localhost:8092/hello

posted on 2018-07-01 11:19  隔岸观火  阅读(124)  评论(0编辑  收藏  举报

导航