<?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_location/</link>
<title><![CDATA[Nginx Location 语法，与简单配置]]></title> 
<author>刘新修 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[web服务器]]></category>
<pubDate>Thu, 30 Sep 2010 16:23:41 +0000</pubDate> 
<guid>http://pic1.liuxinxiu.com:80/nginx_location/</guid> 
<description>
<![CDATA[ 
	<p>一、介绍Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx，它的发音为&ldquo;engine X&rdquo;， 是一个高性能的HTTP和反向代理服务器，同时也是一个IMAP/POP3/SMTP 代理服务器．<br />二、Location语法语法：location [=&#124;~&#124;~*&#124;^~] /uri/ &#123; &hellip; &#125;<br />注：<br />1、~&nbsp;&nbsp; 为区分大小写匹配<br />2、~* 为不区分大小写匹配<br />3、!~和!~*分别为区分大小写不匹配及不区分大小写不匹配<br />示例一：<br />location&nbsp; / &#123; &#125;<br />匹配任何查询，因为所有请求都以 / 开头。但是正则表达式规则将被优先和查询匹配。<br />示例二：<br />location =/ &#123;&#125;<br />仅仅匹配/<br />示例三：<br />location ~* &#92;.(gif&#124;jpg&#124;jpeg)$ ｛<br />rewrite &#92;.(gif&#124;jpg)$ /logo.png;<br />｝<br />注：不区分大小写匹配任何以gif，jpg，jpeg结尾的文件<br />三、ReWrite语法<br />last - 基本上都用这个Flag。<br />break - 中止Rewirte，不在继续匹配<br />redirect - 返回临时重定向的HTTP状态302<br />permanent - 返回永久重定向的HTTP状态301<br />1、下面是可以用来判断的表达式：<br />-f和!-f用来判断是否存在文件<br />-d和!-d用来判断是否存在目录<br />-e和!-e用来判断是否存在文件或目录<br />-x和!-x用来判断文件是否可执行<br />2、下面是可以用作判断的全局变量<br />例：<a href="http://localhost:88/test1/test2/test.php">http://localhost:88/test1/test2/test.php</a><br />$host：localhost<br />$server_port：88<br />$request_uri：<a href="http://localhost:88/test1/test2/test.php">http://localhost:88/test1/test2/test.php</a><br />$document_uri：/test1/test2/test.php<br />$document_root：D:&#92;nginx/html<br />$request_filename：D:&#92;nginx/html/test1/test2/test.php<br />四、Redirect语法<br />&nbsp;&nbsp;&nbsp; server &#123;<br />&nbsp;&nbsp;&nbsp; listen 80;<br />&nbsp;&nbsp;&nbsp; server_name start.igrow.cn;<br />&nbsp;&nbsp;&nbsp; index index.html index.php;<br />&nbsp;&nbsp;&nbsp; root html;<br />&nbsp;&nbsp;&nbsp; if ($http_host !~ &quot;^www&#92;.itlearner&#92;.com$ &#123;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rewrite ^(.*) <a href="http://www.itlearner.com$1">http://www.itlearner.com$1</a> redirect;<br />&nbsp;&nbsp;&nbsp; &#125;<br />&nbsp;&nbsp;&nbsp; &#125;<br />五、防盗链location ~* &#92;.(gif&#124;jpg&#124;swf)$ &#123;<br />&nbsp; valid_referers none blocked start.igrow.cn sta.igrow.cn;<br />&nbsp; if ($invalid_referer) &#123;<br />&nbsp; rewrite ^/ <a href="http://$host/logo.png">http://$host/logo.png</a>;<br />&nbsp; &#125;<br />&#125;<br />六、根据文件类型设置过期时间<br />location ~* &#92;.(js&#124;css&#124;jpg&#124;jpeg&#124;gif&#124;png&#124;swf)$ &#123;<br />if (-f $request_filename) &#123;<br />&nbsp;&nbsp; expires&nbsp;&nbsp;&nbsp; 1h;<br />&nbsp;&nbsp; break;<br />&#125;<br />&#125;<br />七、禁止访问某个目录<br />location ~* &#92;.(txt&#124;doc)$&#123; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; root /data/www/wwwroot/linuxtone/test;<br />&nbsp;&nbsp;&nbsp; deny all;<br />&#125;<br />&nbsp;</p><p>++ 一些可用的全局变量<br />$args<br />$content_length<br />$content_type<br />$document_root<br />$document_uri<br />$host<br />$http_user_agent<br />$http_cookie<br />$limit_rate<br />$request_body_file<br />$request_method<br />$remote_addr<br />$remote_port<br />$remote_user<br />$request_filename<br />$request_uri<br />$query_string<br />$scheme<br />$server_protocol<br />$server_addr<br />$server_name<br />$server_port<br />$uri</p><p>&nbsp;</p>
]]>
</description>
</item><item>
<link>http://pic1.liuxinxiu.com:80/nginx_location/#blogcomment</link>
<title><![CDATA[[评论] Nginx Location 语法，与简单配置]]></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_location/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>