nginx:loadBalance

nginx负载均衡
http
{
      #include       conf/mime.types;
      include       mime.types;
      default_type  application/octet-stream;
      include       vhost/*.conf;

      keepalive_timeout 120;

      tcp_nodelay on;

      upstream  www.samson.com  {
              server   127.0.0.1:8080;
              # server   192.168.1.3:80;
              # server   192.168.1.4:80;
              # server   192.168.1.5:80;
      }

      server
      {
              listen  80;
              server_name  www.samson.com;

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

              log_format  www_samson_com  '$remote_addr - $remote_user [$time_local] $request '
                                '"$status" $body_bytes_sent "$http_referer" '
                                '"$http_user_agent" "$http_x_forwarded_for"';
              access_log  logs/www.log  www_samson_com;
      }

}

在http节点里添加:
#Define the IP and device status of the load balancing device
upstream myServer {  
    server 127.0.0.1:9090 down;
    server 127.0.0.1:8080 weight=2;
    server 127.0.0.1:6060;
    server 127.0.0.1:7070 backup;
} Add proxy_pass
under the server node that needs to use load http:/
/myServer;
The status of each upstream device:
down means that the previous server does not participate in the load temporarily. The
default weight is 1. The larger the weight, the greater the weight of the load.
max_fails : The default number of allowable requests to fail is 1. When the maximum number of times is exceeded, the error defined by the proxy_next_upstream module will be returned.
fail_timeout: The time to pause after max_fails failures.
backup: When all other non-backup machines are down or busy, request the backup machine. So this machine will be the least stressful.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326270788&siteId=291194637