<?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/linux_nginx_reverse_proxy/</link>
<title><![CDATA[【原创】Linux 配置Nginx反向代理（可用于负载均衡）]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[web服务器]]></category>
<pubDate>Wed, 29 Sep 2010 09:38:18 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/linux_nginx_reverse_proxy/</guid> 
<description>
<![CDATA[ 
	<p><strong>反向代理是什么？</strong></p><p>反向代理指以代理服务器来接受Internet上的连接请求，然后将请求转发给内部(或其他)网络上的服务器，并将从服务器上得到的结果返回给Internet上请求连接的客户端。</p><p><strong>实现方法：</strong></p><p>比如我想在Nginx上建一个<strong><span style="color: #ff0000">bbb</span></strong>的域名，使用NGINX通过该域名反向代理访问<strong><span style="color: #0000ff">百度</span></strong>网站，首先在把bbb添加值本机HOST文件中，WINDOWS机器在：<span style="color: #0000ff"><strong>C:&#92;WINDOWS&#92;system32&#92;drivers&#92;etc</strong></span> 下修改hosts 用记事本打开在127.0.0.1 下一行添加：</p><p>127.0.0.1 localhost <br /><span style="color: #0000ff">221.221.161.147 bbb</span></p><p>IP地址部分对应你的LINUX主机IP</p><p>bbb 为测试域名</p><p>再在Linux上修改Nginx的配置文件，添加如下：</p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy1.jpg"><img height="250" alt="" width="849" src="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy1.jpg" /></a></p><p>server<br />&#123;<br />listen 80;<br />server_name bbb;</p><p>location / &#123;<br />proxy_pass <a href="http://www.baidu.com/">http://www.baidu.com/</a>;<br />proxy_redirect off;<br />proxy_set_header X-Real-IP $remote_addr;<br />proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br />&#125;<br />&#125;</p><p>-----------------------------------------------------------------------------------------------------------------</p><p>添加好后，先执行：/usr/local/nginx/sbin/nginx -t 检查配置是否正常，如果显示：the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful 则正常，否则按错误提示修改配置。</p><p>再执行 kill -HUP `cat /usr/local/nginx/logs/nginx.pid` 使配置生效，域名解析生效后就可以通过BBB 访问百度了。</p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy_baidu1.jpg"><img height="363" alt="" width="640" src="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy_baidu1.jpg" /></a></p><p><a target="_blank" href="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy_baidu2.jpg"><img height="381" alt="" width="653" src="http://at.liuxinxiu.com/2010/09/image/linux_nginx_conf_proxy_baidu2.jpg" /></a></p><p>=================================================================</p><p>server<br />&nbsp;&#123;<br />&nbsp;&nbsp;&nbsp; &nbsp;listen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8080;<br />&nbsp;&nbsp;&nbsp; &nbsp;server_name&nbsp;&nbsp;&nbsp;&nbsp; 192.168.2.127;<br />&nbsp;<br />&nbsp;&nbsp;&nbsp; &nbsp;location / &#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;proxy_pass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.baidu.com/">http://www.baidu.com/</a>;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;proxy_redirect&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; off;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;proxy_set_header&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X-Real-IP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $remote_addr;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;proxy_set_header&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X-Forwarded-For $proxy_add_x_forwarded_for;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&#125;<br />&nbsp;&#125;</p><p>==============================================</p><p>转载请标明出处：<a href="http://liuxinxiu.com/linux_nginx_reverse_proxy/">http://liuxinxiu.com/linux_nginx_reverse_proxy/</a></p>
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/linux_nginx_reverse_proxy/#blogcomment11</link>
<title><![CDATA[[评论] 【原创】Linux 配置Nginx反向代理（可用于负载均衡）]]></title> 
<author>一零八八 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sat, 13 Nov 2010 09:39:31 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/linux_nginx_reverse_proxy/#blogcomment11</guid> 
<description>
<![CDATA[ 
	如何用于均衡负载啊?
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/linux_nginx_reverse_proxy/#blogcomment12</link>
<title><![CDATA[[评论] 【原创】Linux 配置Nginx反向代理（可用于负载均衡）]]></title> 
<author>一零八八 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 15 Nov 2010 09:23:39 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/linux_nginx_reverse_proxy/#blogcomment12</guid> 
<description>
<![CDATA[ 
	反向代理不就是通过a服务器代理到b么?你那样的均衡负载虽然减轻了a服务器的资源消耗,但是所有的访问还是走a,流量压力不还是没变么?
]]>
</description>
</item>
</channel>
</rss>