<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hello, SA &#187; nginx</title>
	<atom:link href="http://blog.helosa.org/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.helosa.org</link>
	<description>Could u fix the problem for me ?</description>
	<lastBuildDate>Sat, 04 Sep 2010 19:51:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>个人主页上线</title>
		<link>http://blog.helosa.org/2010/08/01/homepage.html</link>
		<comments>http://blog.helosa.org/2010/08/01/homepage.html#comments</comments>
		<pubDate>Sat, 31 Jul 2010 16:06:56 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=294</guid>
		<description><![CDATA[开了个个人主页，全手工书写html ，且极其简洁，全英文。 http://www.helosa.org/ 写了个nginx module ，第一次写，纯练练手，业务有个需求，想用nginx module 来完成，就试着写一个来练习下先。 这个模块很简单，就是定义返回头的server 的值。以前lighttpd 有个 server.tag 的配置，就是差不多的用途的。 这个模块是在nginx 配置的 server 栏定义的，但直到使用时，我才发现，其实这个模块应该是放在main 那里才合适的。。。呃。。。算了，不改了！]]></description>
			<content:encoded><![CDATA[<p>开了个个人主页，全手工书写html ，且极其简洁，全英文。</p>
<p><a href="http://www.helosa.org/" target="_blank">http://www.helosa.org/</a></p>
<p>写了个nginx module ，第一次写，纯练练手，业务有个需求，想用nginx module 来完成，就试着写一个来练习下先。</p>
<p>这个模块很简单，就是定义返回头的server 的值。以前lighttpd 有个 server.tag 的配置，就是差不多的用途的。</p>
<p>这个模块是在nginx 配置的 server 栏定义的，但直到使用时，我才发现，其实这个模块应该是放在main 那里才合适的。。。呃。。。算了，不改了！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/08/01/homepage.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx-0.8.42 的一个新feature</title>
		<link>http://blog.helosa.org/2010/06/28/nginx-new-feature.html</link>
		<comments>http://blog.helosa.org/2010/06/28/nginx-new-feature.html#comments</comments>
		<pubDate>Sun, 27 Jun 2010 18:44:49 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=269</guid>
		<description><![CDATA[nginx 0.8.42 有个新功能： Feature: a text answer may be added to a &#8220;return&#8221; directive. (via nginx.org ) 这个功能其实很有趣，当然自己写也不难，官方实现了就最好。 找了下，找不到相关的配置说明，只好自己摸索一下吧。一试就出来了，真神奇，哈哈。 三步走（./configure ; make ; make install）安装好 nginx 后，在配置上加一段： location /iloveu/ { return 200 &#8220;iloveu&#8221; ; } 同时把 default_type  application/octet-stream; 修改为 default_type  text/plain; 如果是前者的话，不会看到字符串，而会下载的噢。 启动 nginx 后，curl -i http://127.0.0.1/iloveu/ HTTP/1.1 200 OK Server: nginx/0.8.42 Date: Sun, 27 [...]]]></description>
			<content:encoded><![CDATA[<p>nginx 0.8.42 有个新功能：</p>
<p>Feature: a text answer may be added to a &#8220;return&#8221; directive. (via nginx.org )</p>
<p>这个功能其实很有趣，当然自己写也不难，官方实现了就最好。</p>
<p>找了下，找不到相关的配置说明，只好自己摸索一下吧。一试就出来了，真神奇，哈哈。</p>
<p>三步走（./configure ; make ; make install）安装好 nginx 后，在配置上加一段：</p>
<div id="_mcePaste">location /iloveu/ {</div>
<div id="_mcePaste">return 200 &#8220;iloveu&#8221; ;</div>
<div id="_mcePaste">}</div>
<div>同时把</div>
<div>default_type  application/octet-stream;</div>
<div>修改为</div>
<div>default_type  text/plain;</div>
<div></div>
<div>如果是前者的话，不会看到字符串，而会下载的噢。</div>
<div>启动 nginx 后，curl -i http://127.0.0.1/iloveu/</div>
<div>
<div>HTTP/1.1 200 OK</div>
<div>Server: nginx/0.8.42</div>
<div>Date: Sun, 27 Jun 2010 18:44:04 GMT</div>
<div>Content-Type: text/plain</div>
<div>Content-Length: 3</div>
<div>Connection: keep-alive</div>
<div></div>
<div>iloveu</div>
</div>
<div>就这样玩玩吧。</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/06/28/nginx-new-feature.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>debian 下nginx 快速搭建FCGI环境</title>
		<link>http://blog.helosa.org/2010/05/14/nginx-fcgi.html</link>
		<comments>http://blog.helosa.org/2010/05/14/nginx-fcgi.html#comments</comments>
		<pubDate>Fri, 14 May 2010 06:41:51 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=256</guid>
		<description><![CDATA[我的想法是。。。快点，快点，再快点！！ apt-get install spawn-fcgi php5-cgi 用 spawn-fcgi 启动 fcgi ， spawn-fcgi -a 127.0.0.1 -p 8000 -u nobody -f /usr/bin/php-cgi -C 5 ; 在 nginx 里配置加一句： location ~ \.php$ { fastcgi_pass 127.0.0.1:8000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/nginx/html$fastcgi_script_name; include fastcgi_params; } 然后把一个 php 放在 /home/nginx/html 里，就可以使用了。]]></description>
			<content:encoded><![CDATA[<p>我的想法是。。。快点，快点，再快点！！</p>
<p>apt-get install spawn-fcgi php5-cgi</p>
<p>用 spawn-fcgi 启动 fcgi ，</p>
<p>spawn-fcgi -a 127.0.0.1 -p 8000 -u nobody -f /usr/bin/php-cgi -C 5 ;</p>
<p>在 nginx 里配置加一句：<br />
location ~ \.php$ {<br />
fastcgi_pass   127.0.0.1:8000;<br />
fastcgi_index  index.php;<br />
fastcgi_param  SCRIPT_FILENAME  /home/nginx/html$fastcgi_script_name;<br />
include        fastcgi_params;<br />
}</p>
<p>然后把一个 php 放在 /home/nginx/html 里，就可以使用了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/05/14/nginx-fcgi.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx 实现缓和切换新旧首页</title>
		<link>http://blog.helosa.org/2010/05/13/nginx-index.html</link>
		<comments>http://blog.helosa.org/2010/05/13/nginx-index.html#comments</comments>
		<pubDate>Thu, 13 May 2010 05:49:36 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=253</guid>
		<description><![CDATA[最近首页要改版，瞎折腾，还要新首页和旧首页并行服务，只有网友点击了“新版首页”的按钮后，才会显示新版首页，否则，显示旧版首页。 灵感来自 ayou 的一段配置，我的实现原理如下： 网友点击了切换按钮以后，利用 javascript set 一个 cookie ，如 newindex=y ，首页的 / 会作判断cookie ，然后 rewrite 到相应的页面。 具体实现： 1, 网友点击 set cookie，我抄了一段最简单的东西： &#60;html&#62; &#60;head&#62; &#60;title&#62;Welcome &#60;/title&#62; &#60;script type=&#8221;text/javascript&#8221;&#62; function Set_Cookie( name, value, expires, path, domain, secure ) { // set time, it&#8217;s in milliseconds var today = new Date(); today.setTime( today.getTime() ); /* if the [...]]]></description>
			<content:encoded><![CDATA[<p>最近首页要改版，瞎折腾，还要新首页和旧首页并行服务，只有网友点击了“新版首页”的按钮后，才会显示新版首页，否则，显示旧版首页。<br />
灵感来自 ayou 的一段配置，我的实现原理如下：</p>
<p>网友点击了切换按钮以后，利用 javascript set 一个  cookie ，如 newindex=y ，首页的 / 会作判断cookie ，然后 rewrite 到相应的页面。</p>
<p>具体实现：<br />
1,  网友点击 set cookie，我抄了一段最简单的东西：</p>
<div id="_mcePaste">&lt;html&gt;</div>
<div id="_mcePaste">&lt;head&gt;</div>
<div id="_mcePaste">&lt;title&gt;Welcome &lt;/title&gt;</div>
<div id="_mcePaste">&lt;script type=&#8221;text/javascript&#8221;&gt;</div>
<div id="_mcePaste">function Set_Cookie( name, value, expires, path, domain, secure )</div>
<div id="_mcePaste">{</div>
<div id="_mcePaste">// set time, it&#8217;s in milliseconds</div>
<div id="_mcePaste">var today = new Date();</div>
<div id="_mcePaste">today.setTime( today.getTime() );</div>
<div id="_mcePaste">/*</div>
<div id="_mcePaste">if the expires variable is set, make the correct</div>
<div id="_mcePaste">expires time, the current script below will set</div>
<div id="_mcePaste">it for x number of days, to make it for hours,</div>
<div id="_mcePaste">delete * 24, for minutes, delete * 60 * 24</div>
<div id="_mcePaste">*/</div>
<div id="_mcePaste">if ( expires )</div>
<div id="_mcePaste">{</div>
<div id="_mcePaste">expires = expires * 1000 * 60 * 60 * 24;</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">var expires_date = new Date( today.getTime() + (expires) );</div>
<div id="_mcePaste">document.cookie = name + &#8220;=&#8221; +escape( value ) +</div>
<div id="_mcePaste">( ( expires ) ? &#8220;;expires=&#8221; + expires_date.toGMTString() : &#8220;&#8221; ) +</div>
<div id="_mcePaste">( ( path ) ? &#8220;;path=&#8221; + path : &#8220;&#8221; ) +</div>
<div id="_mcePaste">( ( domain ) ? &#8220;;domain=&#8221; + domain : &#8220;&#8221; ) +</div>
<div id="_mcePaste">( ( secure ) ? &#8220;;secure&#8221; : &#8220;&#8221; );</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">&lt;/script&gt;</div>
<div id="_mcePaste">&lt;/head&gt;</div>
<div id="_mcePaste">&lt;body bgcolor=&#8221;white&#8221; text=&#8221;black&#8221;&gt;</div>
<div id="_mcePaste">&lt;center&gt;&lt;h1&gt;it is a test&lt;/h1&gt;&lt;/center&gt;</div>
<div id="_mcePaste">&lt;a href=&#8221;#&#8221; target=&#8221;_blank&#8221; onclick=&#8221;Set_Cookie( &#8216;newindex&#8217;, &#8216;y&#8217;, 30, &#8216;/&#8217;, &#8221;, &#8221; );window.location.href=&#8217;http://www.helosa.org/&#8217;;&#8221;&gt;我要访问新首页&lt;/a&gt;</div>
<div id="_mcePaste">&lt;/body&gt;</div>
<div id="_mcePaste">&lt;/html&gt;</div>
<p>2，nginx 配置：</p>
<p>location =/ {</p>
<p>root html ;<br />
index index.html ;<br />
if ( $cookie_newindex = &#8220;y&#8221; )<br />
{<br />
rewrite ^/*$ /index_new.html break;<br />
}</p>
<p>}</p>
<p>其中  /index.html 是旧首页，/index_new.html 是新首页。<br />
如此一来，网友访问 <a href="http://www.helosa.org/" target="_blank">http://www.helosa.org/</a> 时，  location / 就会根据cookie rewrite 到相应的首页。但是要注意的是，<br />
<a href="http://www.helosa.org/index.html" target="_blank">http://www.helosa.org/index.html</a><br />
<a href="http://www.helosa.org/index_new.html" target="_blank">http://www.helosa.org/index_new.html</a><br />
访问的是正确的页面，因为判断 cookie 只在 / 做。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/05/13/nginx-index.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx 内存膨胀的一个bug</title>
		<link>http://blog.helosa.org/2010/04/10/nginx-bug.html</link>
		<comments>http://blog.helosa.org/2010/04/10/nginx-bug.html#comments</comments>
		<pubDate>Sat, 10 Apr 2010 02:59:52 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=207</guid>
		<description><![CDATA[我描述一下这个 bug 。 nginx, 用作代理，proxy next upstream 里配置了 404 就next ，然后过了一段时间就发现，一些 worker 占用的内存竟然达到 几百m,通常只是几十m 而已。一不小心占满了内存，用上了 swap （有些机器把 swap 关掉的话，就直接卡死，ping 不通了），load 就上去了，如果不能及时把这个 worker kill 了，那也完蛋了。 我说说这个 bug 的触发条件吧 nginx 里配置了 proxy_next_upstream error timeout http_404; http_404 是指，后端返回 404 的话，就把请求往下一个后端发。 upstream 的配置分以下几种情况： upstream { server 192.168.51.1 ; server 192.168.51.2 ; } 这种情况下，如果 51.1 和 51.2 都404，那么nginx 直接返回给用户 404 [...]]]></description>
			<content:encoded><![CDATA[<p>我描述一下这个 bug 。<br />
nginx, 用作代理，proxy next upstream 里配置了 404 就next ，然后过了一段时间就发现，一些 worker 占用的内存竟然达到 几百m,通常只是几十m 而已。一不小心占满了内存，用上了 swap （有些机器把 swap 关掉的话，就直接卡死，ping 不通了），load 就上去了，如果不能及时把这个 worker kill 了，那也完蛋了。</p>
<p>我说说这个 bug 的触发条件吧<br />
nginx 里配置了<br />
proxy_next_upstream error timeout http_404;<br />
http_404 是指，后端返回 404 的话，就把请求往下一个后端发。</p>
<p>upstream 的配置分以下几种情况：<br />
upstream {<br />
server 192.168.51.1 ;<br />
server 192.168.51.2 ;<br />
}<br />
这种情况下，如果 51.1 和 51.2 都404，那么nginx 直接返回给用户 404 了。</p>
<p>upstream {<br />
server 192.168.51.1 ;<br />
server 192.168.51.2 backup ;<br />
}<br />
请求会卡死，负责处理这个请求的 worker 占用的内存会慢慢增大，也就是我说的那个情况了。即使这个请求取消了，这个 worker 占用的内存仍然会膨胀。<br />
backup ，只是为了 51.1 在挂的时候，可以顶上，但想不到竟然触发了这个 bug 。。。<br />
我测试了 0.6.39 ，0.7.65 , 0.8.32 ，这个 bug 都会存在。</p>
<p>upstream {<br />
server 192.168.51.1 ;<br />
}<br />
如果只配置了一个后端，其实也是很快返回404 的，不会卡死。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
结论：<br />
如果配置了 proxy_next_upstream http_404，千万别配置两个后端，其中一个后端是 backup 的。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/04/10/nginx-bug.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>零编码 nginx + html 实现山寨版url shorten 服务</title>
		<link>http://blog.helosa.org/2010/03/13/nginx-html-url-shorten.html</link>
		<comments>http://blog.helosa.org/2010/03/13/nginx-html-url-shorten.html#comments</comments>
		<pubDate>Sat, 13 Mar 2010 06:14:16 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[memcache]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[nosql]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=187</guid>
		<description><![CDATA[nginx 有个 memcache 的模块，可以读取 memcache 里的数据。但这个模块很简单，只能get，不能set。如果要set 就必须依靠别的方式了。 今天浏览一下nginx wiki module 的时候，发现国人写了一个功能稍多一点的模块，叫 memc_module ，几乎已经实现了 memcache 的所有tcp 协议。 路过见到，那我就玩玩啦，尝试下不用动态语言实现 url shorten 。 安装 memc module ，按照wiki 上面说的安装吧。 启动 memcache ，memcached -d 。 nginx 配置下，然后启动nginx &#8230; location / { root   html; index  index.html index.htm; rewrite &#8220;^(.*)$&#8221; /hello?key=$1 last; } location /hello { memc_pass 127.0.0.1:11211 ; set $memc_key $arg_key [...]]]></description>
			<content:encoded><![CDATA[<p>nginx 有个 memcache 的模块，可以读取 memcache 里的数据。但这个模块很简单，只能get，不能set。如果要set 就必须依靠别的方式了。</p>
<div id=":14b">今天浏览一下nginx wiki module 的时候，发现国人写了一个功能稍多一点的模块，叫 memc_module ，几乎已经实现了 memcache 的所有tcp 协议。<br />
路过见到，那我就玩玩啦，尝试下不用动态语言实现 url shorten 。</p>
<p>安装 memc module ，按照wiki 上面说的安装吧。</p>
<p>启动 memcache ，memcached -d 。</p>
<p>nginx 配置下，然后启动nginx<br />
&#8230;<br />
location / {<br />
root   html;<br />
index  index.html index.htm;<br />
rewrite &#8220;^(.*)$&#8221; /hello?key=$1 last;<br />
}</p>
<p>location /hello {<br />
memc_pass <a href="http://127.0.0.1:11211/" target="_blank">127.0.0.1:11211</a> ;<br />
set $memc_key $arg_key ;<br />
}<br />
&#8230;</p>
<p>写html ，写个form 吧，用 post 把原始的url 提交给 nginx ，然后nginx 在对 memcache 做set 操作。这个是 value 部分，还有一个key 的部分，可以用js 生成一个随机数提交。<br />
这里，我用curl 模拟一下这个 form 的动作，其中，就当我的随机数是 hello 吧<br />
curl &#8211;data &#8220;&lt;html&gt;&lt;body&gt;&lt;meta http-equiv=\&#8221;refresh\&#8221; content=\&#8221;0;url=<a href="http://www.163.com/" target="_blank">http://blog.helosa.org</a>\&#8221;&gt;&lt;/body&gt;&lt;/html&gt;&#8221; <a href="http://127.0.0.1/hello?key=/163" target="_blank">http://127.0.0.1/hello?key=/hello</a></p>
<p>在这句话里，<br />
key 是  /hello<br />
value 是 &lt;html&gt;&lt;body&gt;&lt;meta http-equiv=&#8221;refresh&#8221; content=&#8221;0;url=<a href="http://www.163.com/" target="_blank">http://blog.helosa.org</a>&#8220;&gt;&lt;/body&gt;&lt;/html&gt;</p>
<p>然后，我们访问 <a href="http://127.0.0.1/163" target="_blank">127.0.0.1/163</a> 是，就会跳转到我的blog首页了。</p>
<p>哈哈，url shorten 的服务就是这样实现了，实在有点山寨！</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/03/13/nginx-html-url-shorten.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nginx proxy_pass 里的&#8221;/&#8221;</title>
		<link>http://blog.helosa.org/2010/02/10/nginx-proxy_pass.html</link>
		<comments>http://blog.helosa.org/2010/02/10/nginx-proxy_pass.html#comments</comments>
		<pubDate>Tue, 09 Feb 2010 18:09:57 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://lazybug.me/?p=74</guid>
		<description><![CDATA[见配置，摘自nginx.conf 里的server 段： server { listen 80; server_name abc.163.com ; location / { proxy_pass http://ent.163.com/ ; } location /star/ { proxy_pass http://ent.163.com ; } } 里面有两个location，我先说第一个，/ 。其实这里有两种写法，分别是： location / { proxy_pass http://ent.163.com/ ; } location / { proxy_pass http://ent.163.com ; } 出来的效果都一样的。 第二个location，/star/。同样两种写法都有，都出来的结果，就不一样了。 location /star/ { proxy_pass http://ent.163.com ; } 当访问 http://abc.163.com/star/ 的时候，nginx 会代理访问到 http://ent.163.com/star/ [...]]]></description>
			<content:encoded><![CDATA[<p>见配置，摘自nginx.conf 里的server 段：</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">server {
<span style="color: #00007f;">listen</span> <span style="color: #ff0000;">80</span>;
server_name abc.163.com ;
<span style="color: #00007f;">location</span> / {
proxy_pass http://ent.163.com/ ;
}
<span style="color: #00007f;">location</span> /star/ {
proxy_pass http://ent.163.com ;
}
}</pre></div></div>

<p>里面有两个location，我先说第一个，/ 。其实这里有两种写法，分别是：</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">location</span> / {
proxy_pass http://ent.163.com/ ;
}</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">location</span> / {
proxy_pass http://ent.163.com ;
}</pre></div></div>

<p>出来的效果都一样的。</p>
<p>第二个location，/star/。同样两种写法都有，都出来的结果，就不一样了。</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">location</span> /star/ {
proxy_pass http://ent.163.com ;
}</pre></div></div>

<p>当访问 http://abc.163.com/star/ 的时候，nginx 会代理访问到 http://ent.163.com/star/ ，并返回给我们。</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">location</span> /star/ {
proxy_pass http://ent.163.com/ ;
}</pre></div></div>

<p>当访问 http://abc.163.com/star/ 的时候，nginx 会代理访问到 http://ent.163.com/ ，并返回给我们。</p>
<p>这两段配置，分别在于， proxy_pass http://ent.163.com<span style="color: #ff0000;">/</span> ; 这个&#8221;/&#8221;，令到出来的结果完全不同。</p>
<p>前者，相当于告诉nginx，我这个location，是代理访问到http://ent.163.com 这个server的，我的location是什么，nginx 就把location 加在proxy_pass 的 server 后面，这里是/star/，所以就相当于 http://ent.163.com/star/。如果是location /blog/ ，就是代理访问到 http://ent.163.com/blog/。</p>
<p>后者，相当于告诉nginx，我这个location，是代理访问到http://ent.163.com/的，http://abc.163.com/star/ == http://ent.163.com/ ，可以这样理解。改变location，并不能改变返回的内容，返回的内容始终是http://ent.163.com/ 。 如果是location /blog/ ，那就是 http://abc.163.com/blog/ == http://ent.163.com/ 。</p>
<p>这样，也可以解释了上面那个location / 的例子，/ 嘛，加在server 的后面，仍然是 / ，所以，两种写法出来的结果是一样的。</p>
<p>PS: 如果是 location ~* ^/start/(.*)\.html 这种正则的location，是不能写&#8221;/&#8221;上去的，nginx -t 也会报错的了。因为，路径都需要正则匹配了嘛，并不是一个相对固定的locatin了，必然要代理到一个server。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/02/10/nginx-proxy_pass.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于nginx的last-modified返回头</title>
		<link>http://blog.helosa.org/2010/01/28/nginx-last-modified.html</link>
		<comments>http://blog.helosa.org/2010/01/28/nginx-last-modified.html#comments</comments>
		<pubDate>Thu, 28 Jan 2010 15:34:12 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://lazybug.me/?p=49</guid>
		<description><![CDATA[squid 不能缓存cache-control在65秒以下的页面，详见ayou同学的这篇文章：http://sudone.com/linux/squid_cache_65s.html 根据文章所说，如果想实现65秒以下的缓存呢，用last-modified头吧。 今天遇到了一个比较郁闷的事，就是架设在squid后的一台nginx，随意访问一个静态页面，死活不出last-modified头。也没作什么特殊的配置，我自己新装一个nginx，测试之。 $curl -I 127.0.0.1 HTTP/1.1 200 OK Server: nginx/0.8.32 Date: Thu, 28 Jan 2010 14:57:11 GMT Content-Type: text/html Content-Length: 151 Last-Modified: Thu, 28 Jan 2010 03:07:20 GMT Connection: keep-alive Accept-Ranges: bytes 很正常嘛，不作任何配置时默认是会有last-modified的。 后来还是经ayou同学的提醒，因为使用了ssi。。。 使用了ssi，nginx 就假设你这个页面动态的，谁知道你include的页面上次修改时间啊，当然也就不给你返回last-modified头了。 另外，使用nginx的 http_sub_module时，也不会出这个头的。在测试机上试试，加了个ssi on $curl -I http://127.0.0.1 HTTP/1.1 200 OK Server: nginx/0.8.32 Date: Thu, 28 Jan 2010 14:57:32 [...]]]></description>
			<content:encoded><![CDATA[<p>squid 不能缓存cache-control在65秒以下的页面，详见ayou同学的这篇文章：http://sudone.com/linux/squid_cache_65s.html</p>
<p>根据文章所说，如果想实现65秒以下的缓存呢，用last-modified头吧。</p>
<p>今天遇到了一个比较郁闷的事，就是架设在squid后的一台nginx，随意访问一个静态页面，死活不出last-modified头。也没作什么特殊的配置，我自己新装一个nginx，测试之。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$curl</span> <span style="color: #660033;">-I</span> 127.0.0.1
HTTP<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span> <span style="color: #000000;">200</span> OK
Server: nginx<span style="color: #000000; font-weight: bold;">/</span>0.8.32
Date: Thu, <span style="color: #000000;">28</span> Jan <span style="color: #000000;">2010</span> <span style="color: #000000;">14</span>:<span style="color: #000000;">57</span>:<span style="color: #000000;">11</span> GMT
Content-Type: text<span style="color: #000000; font-weight: bold;">/</span>html
Content-Length: <span style="color: #000000;">151</span>
Last-Modified: Thu, <span style="color: #000000;">28</span> Jan <span style="color: #000000;">2010</span> 03:07:<span style="color: #000000;">20</span> GMT
Connection: keep-alive
Accept-Ranges: bytes</pre></div></div>

<p>很正常嘛，不作任何配置时默认是会有last-modified的。</p>
<p>后来还是经ayou同学的提醒，因为使用了ssi。。。</p>
<p>使用了ssi，nginx 就假设你这个页面动态的，谁知道你include的页面上次修改时间啊，当然也就不给你返回last-modified头了。</p>
<p>另外，使用nginx的 http_sub_module时，也不会出这个头的。在测试机上试试，加了个ssi on</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$curl</span> <span style="color: #660033;">-I</span> http:<span style="color: #000000; font-weight: bold;">//</span>127.0.0.1
HTTP<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span> <span style="color: #000000;">200</span> OK
Server: nginx<span style="color: #000000; font-weight: bold;">/</span>0.8.32
Date: Thu, <span style="color: #000000;">28</span> Jan <span style="color: #000000;">2010</span> <span style="color: #000000;">14</span>:<span style="color: #000000;">57</span>:<span style="color: #000000;">32</span> GMT
Content-Type: text<span style="color: #000000; font-weight: bold;">/</span>html
Connection: keep-alive</pre></div></div>

<p>果然是ssi。。。</p>
<p>mark 一下，以前就试过了，今天竟然忘了！！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/01/28/nginx-last-modified.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>wordpress 上传大图爆http error</title>
		<link>http://blog.helosa.org/2010/01/13/wordpress-http-error.html</link>
		<comments>http://blog.helosa.org/2010/01/13/wordpress-http-error.html#comments</comments>
		<pubDate>Wed, 13 Jan 2010 15:27:27 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://lazybug.me/?p=28</guid>
		<description><![CDATA[在wordpress上传一个1.1M左右size的图，竟然爆http error。。。google 了一下，竟然要配置一下apache 的 mod_security 模块，但我用的是nginx啊。。。 感觉不是wordpress的问题，难道是nginx的配置问题？？查看了一下error log，发现这句 client intended to send too large body: 1134408 bytes 原来如此，我以前好像配置过这个，找了一下，作出修改如下： 在location ~ \.php$ 的标签下，加一行 client_max_body_size    8m; 然后重启nginx，我一般这样重启 killall -HUP nginx，OK，上传没问题了！！]]></description>
			<content:encoded><![CDATA[<p>在wordpress上传一个1.1M左右size的图，竟然爆http error。。。google 了一下，竟然要配置一下apache 的 mod_security 模块，但我用的是nginx啊。。。</p>
<p>感觉不是wordpress的问题，难道是nginx的配置问题？？查看了一下error log，发现这句</p>
<p>client intended to send too large body: 1134408 bytes</p>
<p>原来如此，我以前好像配置过这个，找了一下，作出修改如下：</p>
<p>在location ~ \.php$ 的标签下，加一行</p>
<p>client_max_body_size    8m;</p>
<p>然后重启nginx，我一般这样重启 killall -HUP nginx，OK，上传没问题了！！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2010/01/13/wordpress-http-error.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
