With load balancing, you can modify the configuration HTTP node as follows:
#设定http服务器, using its reverse proxy function to provide load balancing support http { #设定mime类型, the type is defined by the Mime.type file include / etc / Nginx / MIME . Types ; Default_type Application / Octet - Stream ; #设定日志格式 Access_log / var / Log / Nginx / Access . Log ; #省略上文有的一些配置节点 # ..... #设定负载均衡的服务器列表 Upstream Mysvr { #weigth参数表示权值, the higher the weight, the greater the chance of being assigned. Server 192.168 . 8.1x : 3128 Weight = 5 ; #本机上的Squid开启3128端口, you don't have to have squid. Server 192.168 . 8.2x : the Weight = 1 ; Server 192.168 . 8.3x : the Weight = 6 ; } Upstream MYSVR2 { #weigth参数表示权值, the higher the weight, the greater the chance of being assigned. Server 192.168 . 8.x : the Weight = 1 ; Server 192.168 . 8.x : the Weight = 6 ; } #第一个虚拟服务器 Server { #侦听192.80 Port of 168.8.x Listen the ; server_name 192.168 . 8.x ; #对aspx后缀的进行负载均衡请求 Location ~ .* \.aspx$ { #定义服务器的默认网站根目录位置 Root / Root ; #定义首页索引文件的名称 Index Index . PHP Index . HTML Index . htm ; list of servers #请求转向mysvr defined Proxy_pass http : //mysvr; #以下是一些反向代理的配置可删除. Proxy_redirect off ; #后端的Web服务器可以通过X-forwarded-for Get the user real IP Proxy_set_header Host $host ; Proxy_set_header X - Real - IP $remote _addr ; Proxy_set_header X - forwarded - for $proxy _add_x_forwarded_for ; #允许客户端请求的最大单文件字节数 client_max_body_size 10m ; #缓冲区代理缓冲用户端请求的最大字节数, client_body_buffer_size 128k ; #nginx跟后端服务器连接超时时间 (proxy connection timed out) Proxy_connect_timeout - ; #连接成功后, back-end server response time (proxy receive timeout) Proxy_read_timeout - ; #设置代理服务器 (nginx) buffer size for saving user header information proxy_buffer_size 4k ; #proxy_buffers缓冲区, the average page is below 32k, so set proxy_buffers 4 32k ; #高负荷下缓冲大小 (proxy_buffers*2) proxy_busy_buffers_size 64k ; #设定缓存文件夹大小, greater than this value, will be passed from the upstream server proxy_temp_file_write_size 64k ; } } }
The above describes the Nginx load Balancer configuration---nginx learning path, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.