wslhs 发表于 2018-11-13 09:58:28

centos6.7上使用nginx实现负载均衡!

http {  
    include       /etc/nginx/mime.types;
  
    default_typeapplication/octet-stream;
  
    log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  
                      '$status $body_bytes_sent "$http_referer" '
  
                      '"$http_user_agent" "$http_x_forwarded_for"';
  
    access_log/var/log/nginx/access.logmain;
  
    sendfile      on;
  
    #tcp_nopush   on;
  
    #keepalive_timeout0;
  
    keepalive_timeout65;
  
    #增加的
  
    upstream    web1 {
  
      server192.168.239.139:80 weight=1 max_fails=2 fail_timeout=30s;
  
      server192.168.239.138:80 weight=1 max_fails=2 fail_timeout=30s;
  
    }
  
    #增加的
  
   server {
  
      listen       80;
  
      server_namelocalhost;
  
      location / {
  
            proxy_passhttp://web1;
  
            root   html;
  
            indexindex.html index.htm;
  
      }
  
    }
  
    #gzipon;
  

  
    # Load config files from the /etc/nginx/conf.d directory
  
    # The default server is in conf.d/default.conf
  
    #include /etc/nginx/conf.d/*.conf;    #这里需要注释掉,不然起不到作用。
  
}


页: [1]
查看完整版本: centos6.7上使用nginx实现负载均衡!