nginx配置负载均衡

在nginx 目录下打开 nginx.conf

在http {

下修改 增加:

upstream redislock{
        server 192.168.0.106:8001 weight=1; // 自己部署到服务地址和端口
        server 192.168.0.106:8002 weight=1; // 自己部署到服务地址和端口
}

location / {
            root   html;
            index  index.html index.htm;
            proxy_pass   http://redislock;
        }
 
如下所示:
upstream redislock{
        server 192.168.0.106:8001 weight=1;
        server 192.168.0.106:8002 weight=1;
    }


    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass   http://redislock;
        }

 

访问:127.0.0.1:80  会轮询请求到服务 

192.168.0.106:8001
192.168.0.106:8002

 

posted @ 2020-04-19 18:57  小污龟  阅读(147)  评论(0编辑  收藏  举报