Nginx负载均衡

配置权重

upstream tomcats {
  server 172.21.13.165:8088 weight=10;
  server 172.21.13.81:8088 weight=1;
}

server {
  listen 80;

  #绕过跨域 这样后端那些接口需要跨域也不用单独配置了。这样 web 页面请求自己当前域名下的request就被转发到内网的服务上去了。

  location / {
    proxy_pass http://tomcats;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  }

}

其他负载均衡策略百度即可

原文地址:https://www.cnblogs.com/michaelcnblogs/p/12509880.html