<?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>蓝色的华 &#187; nginx</title>
	<atom:link href="http://bluehua.org/tag/nginx/feed" rel="self" type="application/rss+xml" />
	<link>http://bluehua.org</link>
	<description>分享所学,backup一切~</description>
	<lastBuildDate>Fri, 13 Apr 2012 14:08:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>nginx反向代理kloxo</title>
		<link>http://bluehua.org/2010/01/14/810.html</link>
		<comments>http://bluehua.org/2010/01/14/810.html#comments</comments>
		<pubDate>Wed, 13 Jan 2010 16:53:59 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[kloxo]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[vps]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=810</guid>
		<description><![CDATA[偶的vps配置真是几经波折。。 最开始 : centos + nginx + fastcgi + php，一个人用，任何修改都是直接ssh到server，一水的root 后来，搬家了,两个人用，加一个菜鸟的明星同学，考虑到傻瓜性，保留了默认安装的控制面板:centos + kloxo。kloxo可以选lighttpd, apache。由于一开始不知道能切apache，就用了lighttpd + fastcgi + php,结果发现每个人开三个fastcgi，128内存基本上就快光了，还有一点不爽的就是wp-super-cache的重写，如果用apache根本不用操心。。 备注:恩，由于kloxo的安全性考虑，每个用户的fastcgi都是单开的，不能共用 现如今，同样的vps配置，5个人共用，不得不再换个思路。首先fastcgi肯定不靠普了，每个人开2个，基本上就靠swap活着了，所以一定要用apache，apache里php以模块运行，多用户可以共用，所以apache进程只需开到2-3个，使用8080端口，然后前端再放nginx做代理，顺便处理静态文件。 恩，思路很简单，但是问题是，kloxo生成的虚拟主机配置文件全是80端口，想hack一下，发现源代码全被zend加密了。后来官网svn找到源码，端口竟然都是80写死在代码里的，修改之后覆盖到server上，发现不能添加域名了，说明版本太新，最后没办法，只能恶心一下了~ 每10秒钟检查一下配置文件，如果发现kloxo生成了80端口的配置文件，立刻替换成8080端口。脚本启动添加到/etc/rc.local里，开机运行。 #!/bin/sh while &#91; &#34;a&#34;=&#34;a&#34; &#93;;do find /home/httpd/ -type f -name &#34;kloxo.*&#34; &#124; xargs grep &#34;:80\\\\&#34; &#62; /tmp/kloxo_port if [ -n &#34;`cat /tmp/kloxo_port`&#34; ];then sh /root/kloxo_changeport.sh &#34;80&#34; &#34;8080&#34; sleep 2 echo &#34;restart httpd&#34; echo [...]]]></description>
			<content:encoded><![CDATA[<p>偶的vps配置真是几经波折。。</p>
<p>最开始 : centos + nginx + fastcgi + php，一个人用，任何修改都是直接ssh到server，一水的root</p>
<p>后来，搬家了,两个人用，加一个菜鸟的明星同学，考虑到傻瓜性，保留了默认安装的控制面板:centos + kloxo。kloxo可以选lighttpd, apache。由于一开始不知道能切apache，就用了lighttpd + fastcgi + php,结果发现每个人开三个fastcgi，128内存基本上就快光了，还有一点不爽的就是wp-super-cache的重写，如果用apache根本不用操心。。</p>
<p>备注:恩，由于kloxo的安全性考虑，每个用户的fastcgi都是单开的，不能共用</p>
<p>现如今，同样的vps配置，5个人共用，不得不再换个思路。首先fastcgi肯定不靠普了，每个人开2个，基本上就靠swap活着了，所以一定要用apache，apache里php以模块运行，多用户可以共用，所以apache进程只需开到2-3个，使用8080端口，然后前端再放nginx做代理，顺便处理静态文件。</p>
<p>恩，思路很简单，但是问题是，kloxo生成的虚拟主机配置文件全是80端口，想hack一下，发现源代码全被zend加密了。后来官网svn找到源码，端口竟然都是80写死在代码里的，修改之后覆盖到server上，发现不能添加域名了，说明版本太新，最后没办法，只能恶心一下了~</p>
<p>每10秒钟检查一下配置文件，如果发现kloxo生成了80端口的配置文件，立刻替换成8080端口。脚本启动添加到/etc/rc.local里，开机运行。</p>

<div class="wp_syntax"><div class="code overflow"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;a&quot;</span>=<span style="color: #ff0000;">&quot;a&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>;<span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">-type</span> f <span style="color: #660033;">-name</span> <span style="color: #ff0000;">&quot;kloxo.*&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;:80\\\<span style="color: #000099; font-weight: bold;">\&quot;</span> &gt; /tmp/kloxo_port 
        if [ -n &quot;</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>kloxo_port<span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot; ];then
                sh /root/kloxo_changeport.sh &quot;</span><span style="color: #000000;">80</span><span style="color: #ff0000;">&quot; &quot;</span><span style="color: #000000;">8080</span><span style="color: #ff0000;">&quot;
                sleep 2
                echo &quot;</span>restart httpd<span style="color: #ff0000;">&quot;
                echo &quot;</span>restart httpd <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #ff0000;">&quot; &gt;&gt; /var/log/httpd_restart.log
                /etc/init.d/httpd restart
        fi
        sleep 10
done</span></pre></div></div>

<p>用到的两个shell脚本下载 : <a href='http://bluehua.org/wp-content/uploads/2010/01/fuck-kloxo.zip'>fuck-kloxo</a></p>
<p>OK，解决完端口问题下面就是配置ngnix代理</p>
<pre>
#仅开了一个进程。。
worker_processes  1;
</pre>
<p>配置代理</p>

<div class="wp_syntax"><div class="code overflow"><pre class="text" style="font-family:monospace;">server {
        limit_conn   myzone  10;
        listen       80;
        server_name  _;
#静态文件不走代理，直接nginx处理
        location ~* .*\.(jpg|jpeg|png|gif|css|js|swf|mp3|avi|flv|xml|zip|rar)$ {
                add_header BlueNoProxy 1;
                expires 30d;
                root /home/httpd/$host/httpdocs;
        } 
#html文件由可能是固态链接，所以404之后依然走代理
        location ~* .*\.(html|htm)$ {
                add_header BlueNoProxy 1;
                root /home/httpd/$host/httpdocs;
                error_page 404 = @proxy;
        }
#这里ip不能用127.0.0.1,kloxo的配置文件里会根据外网ip划分虚拟主机
        location @proxy {
                proxy_pass        http://209.124.50.68:8080;
                proxy_set_header Host $host;
                proxy_set_header  x-real-IP  $remote_addr;
&nbsp;
        }
&nbsp;
        location / {
                proxy_pass        http://209.124.50.68:8080;
                proxy_set_header Host $host;
                proxy_set_header  x-real-IP  $remote_addr;
        }
&nbsp;
   }</pre></div></div>

<p>以上，偶的最新vps配置就over了~</p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2010/01/14/810.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>411 Length Required</title>
		<link>http://bluehua.org/2009/07/23/343.html</link>
		<comments>http://bluehua.org/2009/07/23/343.html#comments</comments>
		<pubDate>Thu, 23 Jul 2009 04:11:38 +0000</pubDate>
		<dc:creator>冥王星2011</dc:creator>
				<category><![CDATA[web dev]]></category>
		<category><![CDATA[411]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://bluehua.org/?p=343</guid>
		<description><![CDATA[如果您恰好使用了ff浏览器(偶用ff3.0)，server端使用了nginx作代理，而某个ajax又恰好传了一个为null的数据，您就会看到这个错误 firefox下点run code运行下面代码,firebug 看控制台 &#60;html&#62; &#60;input type=&#34;button&#34; value=&#34;send null ajax&#34; onclick=&#34;send();&#34; /&#62; &#60;/html&#62; &#60;script&#62; function send&#40;&#41; &#123; var rq = new XMLHttpRequest&#40;&#41;; rq.open&#40;&#34;POST&#34;, &#34;http://bluehua.org/index.php&#34;, true&#41;; rq.send&#40; null &#41;; &#125; &#60;/script&#62; 两种解决方法: client side : rq.send( data ) -&#62; rq.send( data &#124;&#124; ” ); server side : http://rocky.blog.kingtch.com/2008/11/28/fix_nginx_411_length_required/]]></description>
			<content:encoded><![CDATA[<p>如果您恰好使用了ff浏览器(偶用ff3.0)，server端使用了nginx作代理，而某个ajax又恰好传了一个为null的数据，您就会看到这个错误</p>
<p>firefox下点run code运行下面代码,firebug 看控制台</p>

<div class="wp_syntax"><div class="code overflow"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;button&quot;</span> value<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;send null ajax&quot;</span> onclick<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;send();&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>html<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">function</span> send<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> rq <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rq.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;POST&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;http://bluehua.org/index.php&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rq.<span style="color: #660066;">send</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>两种解决方法:<br />
client side : rq.send( data ) -&gt; rq.send( data || ” );<br />
server side :<a href="http://rocky.blog.kingtch.com/2008/11/28/fix_nginx_411_length_required/" target="_blank"> http://rocky.blog.kingtch.com/2008/11/28/fix_nginx_411_length_required/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bluehua.org/2009/07/23/343.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.342 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-22 09:07:50 -->

