<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Snooda]]></title> 
<link>http://www.snooda.com/index</link> 
<description><![CDATA[Snooda's Blog]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Snooda]]></copyright>
<item>
<link>http://www.snooda.com/read/300</link>
<title><![CDATA[wordpress在nginx中的rewrite重写规则]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[nginx]]></category>
<pubDate>Sun, 27 May 2012 04:02:32 +0000</pubDate> 
<guid>http://www.snooda.com/read/300</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;对于wordpress开启静态化url时如何在nginx下配置重写rewrite规则，网上一大抄的一个方式是说这样配置：<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;if (!-e $request_filename)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rewrite ^(.+)$ /index.php?q=$1 last;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;看起来没什么错误，但实际使用中总发现静态文件也被rewrite走了，去nginx官网发现有了新参数：<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;在location /段里加上一句：try_files $uri $uri/ /index.php?q=$uri&$args;<br/><br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;ok了，轻松愉快。<br/><br/><br/><br/>Tags - <a href="http://www.snooda.com/tags/nginx/" rel="tag">nginx</a> , <a href="http://www.snooda.com/tags/wordpress/" rel="tag">wordpress</a>
]]>
</description>
</item><item>
<link>http://www.snooda.com/read/295</link>
<title><![CDATA[为博客nginx日志添加请求域名打印（host字段）及添加其他域跳转到主域]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[nginx]]></category>
<pubDate>Thu, 17 May 2012 09:40:24 +0000</pubDate> 
<guid>http://www.snooda.com/read/295</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;前几天百度快照和流量都恢复了，心情很好，但今天看收录时突然发现迁移前服务器绑定的那个临时域名居然也在收录之列，这个不是一个好的现象，因为如果爬虫同时对两个域名同时抓取，会得到相同的内容，对于重复内容是很不利于收录的。查了下快照，发现百度依旧动作很慢，收录只有一页，还是迁移前的那个测试页，google则全都收录了，怪不得迁移时google非常活跃，现在回想应该不是爬主域名，很可能是发现那个临时域名指向的站点大更新，在爬那个。<br/><br/>&nbsp;&nbsp; 纠结的是nginx默认配置居然不打印请求的host域名，无法考证之前爬虫爬取情况，亡羊补牢，幸亏nginx默认留空了日志第二个字段，打印的是“-”，正好用来打印域名，将-修改为$host，重启后就打印了。<br/><br/><br/>&nbsp;&nbsp; 对于已经收录的临时域名，需要将流量都导入到主域，在nginx里配置了一下301跳转：<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;if ($host = 'tmpdomain.com' )<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#123;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite&nbsp;&nbsp;^/(.*)$&nbsp;&nbsp;http://maindomain.com/$1&nbsp;&nbsp;permanent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/><br/><br/><br/>&nbsp;&nbsp; ok<br/>Tags - <a href="http://www.snooda.com/tags/nginx/" rel="tag">nginx</a> , <a href="http://www.snooda.com/tags/%25E6%2597%25A5%25E5%25BF%2597/" rel="tag">日志</a>
]]>
</description>
</item><item>
<link>http://www.snooda.com/read/285</link>
<title><![CDATA[nginx为js/css开启gzip压缩节省流量]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[nginx]]></category>
<pubDate>Mon, 07 May 2012 06:26:28 +0000</pubDate> 
<guid>http://www.snooda.com/read/285</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;今天发现一个问题，发现博客的js和css都没有gzip压缩，大号js动辄就20几k，很奇怪，以为是迁移导致的某个地方忘了开，查了下，发现之前的也没开，疑惑。<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;我明明在ngix配置文件里加了gzip&nbsp;&nbsp;on;了，但为啥js和css没有开呢，查了下nginx文档，原来默认只对text/html类型的压缩。<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;加了一句：gzip_types application/x-javascript text/css<br/>&nbsp;&nbsp;&nbsp;&nbsp;ok，现在js和css都压缩了，加载速度又提高了不少。<br/><br/><br/><br/><br/><br/>Tags - <a href="http://www.snooda.com/tags/gzip/" rel="tag">gzip</a>
]]>
</description>
</item><item>
<link>http://www.snooda.com/read/254</link>
<title><![CDATA[nginx强制使用https（http到https自动跳转]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[nginx]]></category>
<pubDate>Sun, 11 Mar 2012 02:45:04 +0000</pubDate> 
<guid>http://www.snooda.com/read/254</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;nginx对于使用http访问开启了https的站点会返回400.而浏览器输入网址默认是http的，每次都要去改成https很烦，于是考虑自动跳转的方法，刚开始用的$scheme变量判断，如果不是https则跳转。发现无效。<br/>&nbsp;&nbsp;&nbsp;&nbsp;搜了一下，网上的一大抄们都表示rewrite (.*）https://$host/$1 permanent;可以，光目标地址没考虑端口号就让人感觉不是特别靠谱。试了下，果然不行。<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;想了下，应该是在一开始就被判断出异常，根本没有往后走的缘故。<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;这时找到一个方法：error_page 497 https://$host:$server_port$request_uri;<br/>&nbsp;&nbsp;&nbsp;&nbsp;497表示使用http连接https的错误码。一旦出错让其跳转到https。<br/>&nbsp;&nbsp;&nbsp;&nbsp;搞定<br/>Tags - <a href="http://www.snooda.com/tags/nginx/" rel="tag">nginx</a> , <a href="http://www.snooda.com/tags/http/" rel="tag">http</a> , <a href="http://www.snooda.com/tags/https/" rel="tag">https</a> , <a href="http://www.snooda.com/tags/error_page/" rel="tag">error page</a> , <a href="http://www.snooda.com/tags/rewrite/" rel="tag">rewrite</a>
]]>
</description>
</item>
</channel>
</rss>