<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[刘新修]]></title> 
<link>http://pic1.liuxinxiu.com:80/index.php</link> 
<description><![CDATA[刘新修的个人博客 (Liuxinxiu'S Blog)]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[刘新修]]></copyright>
<item>
<link>http://pic1.liuxinxiu.com:80/nginx_load_balancing/</link>
<title><![CDATA[【原创】nginx负载均衡实例，亲测]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[web服务器]]></category>
<pubDate>Sat, 09 Oct 2010 10:06:43 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/nginx_load_balancing/</guid> 
<description>
<![CDATA[ 
	<p>nginx不单可以作为强大的web服务器，也可以作为一个七层的反向代理服务器，而且nginx还可以按照调度规则实现动态、静态页面的分离，可以按照轮询、ip哈希、URL哈希、权重等多种方式对后端服务器做负载均衡，同时还支持后端服务器的健康检查。</p><p>如果将web服务器集群当做一个城池，那么负载均衡服务器就相当于城门，重要性不言而喻，如果&ldquo;城门&rdquo;关闭了，与外界的通道也就掐断了，如果只有一台nginx负载均衡服务器，当该服务器发生故障时，则会整个网站无法访问，因此，就需要两台以上的nginx负载均衡服务器，实现故障转移与高可用，双机高可用暂不详细介绍。</p><p>下面就是一个生产实例。</p><p>aaa.liuxinxiu.com 和 bbb.liuxinxiu.com 域名均指向 Nginx 所在的服务器IP。</p><p>用户访问<a href="http://aaa.liuxinxiu.com">http://aaa.liuxinxiu.com/</a>，将其负载均衡到120.9.123.121:80、202.108.22.142:80 这两台服务器。<br />用户访问<a href="http://bbb.liuxinxiu.com">http://bbb.liuxinxiu.com/</a>，将其负载均衡到60.5.185.59:80、120.9.123.121:80、202.108.22.142:80 这三台服务器。</p><p>============================================================================</p><p>注意：<br />ip_hash来代替默认的rr方式，即可以将某客户端IP的请求通过哈希算法定位到同一台后端web服务器上，这样避免了session丢失，解决了session问题。但ip_hash指令无法保证后端服务器的负载均衡，可能有些后端服务器接收的请求多，有些后端服务器接收的请求少；这样失去了负载均衡的意义，所以，如果后端的动态应用服务器做到session共享，还是建议采用后端服务器的session共享方式来代替nginx的ip_hash方式。</p><p>===================================================================】】</p><p><strong>以下是AAA组分配的2组负载均衡服务器，规则更加反应速度，快者NGINX优先选择，<span style="color: #ff0000">ip_hash; </span>这种形式只能使用IP分配！</strong></p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing-1.jpg"><img alt="" src="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing-1.jpg" /></a></p><p><strong>BBB组分配的三组负载均衡服务器，采用默认顺序规则，由上至下依次选择，如果最上边60.5.185.59这组服务器DOWN掉选择中间120.9.123.121这组，如果中间这组挂掉则NGINX自动202.108.22.142最下边这组IP主机！</strong></p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing-2.jpg"><img height="288" alt="" width="908" src="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing-2.jpg" /></a></p><p><span style="color: #0000ff"><strong>BBB虚拟主机SERVER中的配置内容：</strong></span></p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing_server_conf-1.jpg"><img alt="" src="http://at.liuxinxiu.com/2010/10/image/nginx_Load_balancing_server_conf-1.jpg" /></a></p><p><strong><span style="color: #0000ff">注，选择中的部分：</span></strong></p><p><span style="color: #ff0000">#root /ftp/101;<br />index index.html index.htm index.php;</span></p><p><span style="color: #ff0000">location ~ .*&#92;.(gif&#124;jpg&#124;jpeg&#124;png&#124;bmp&#124;swf)$ &#123;<br />expires 30d;<br />&#125;</span></p><p><span style="color: #ff0000">location ~ .*&#92;.(htm&#124;html&#124;js&#124;css)$ &#123;<br />expires 1h;<br />&#125;</span></p><p><span style="color: #0000ff"><strong>可以忽略不添加，或者注释掉也可以！！！！！！</strong></span></p><p>AAA在SERVER中的添加内容和BBB类似！</p>
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/nginx_load_balancing/#blogcomment</link>
<title><![CDATA[[评论] 【原创】nginx负载均衡实例，亲测]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/nginx_load_balancing/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>