nginx负载均衡配置

http {

  upstream docker {
      server 192.168.88.106:10001;
      server 192.168.88.106:10002;
      server 192.168.88.106:10003;
       }

  server {
    listen 81;
    server_name localhost;

  location / {
    proxy_pass http://docker;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
   }

}

 

 

 

## 七层负载均衡,写在http{}里面:
#upstream kube-apiserver {
#    server 121.52.238.150:6443;
#    server 61.130.9.196:6443;
#}

#server {
#    listen 6443;
#    server_name localhost;
#    location / {
#        proxy_pass http://kube-apiserver;
#        proxy_set_header Host $host;
#        proxy_set_header X-Real-IP $remote_addr;
#        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#    }
#}


## 四层负载均衡,写在http{}外面:
stream {
    upstream kube-apiserver {
        server 121.52.238.150:6443;
        server 61.130.9.196:6443;
    }
 
    server {
        listen 6443;
        proxy_pass kube-apiserver;
    }

}

 

posted @ 2017-05-07 12:51  chenjianwen  阅读(258)  评论(0编辑  收藏  举报