<?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>iCodex&#039;s Blog &#187; nginx</title> <atom:link href="http://icodex.org/tag/nginx/feed/" rel="self" type="application/rss+xml" /><link>http://icodex.org</link> <description>诡谲</description> <lastBuildDate>Wed, 01 Sep 2010 17:49:50 +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>适用于Directadmin面板的Nginx自动安装脚本</title><link>http://icodex.org/2010/05/directadmin-nginx-automated-installer/</link> <comments>http://icodex.org/2010/05/directadmin-nginx-automated-installer/#comments</comments> <pubDate>Fri, 21 May 2010 04:17:50 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[CentOS]]></category> <category><![CDATA[DirectAdmin]]></category> <category><![CDATA[nginx]]></category><guid isPermaLink="false">http://icodex.org/?p=663</guid> <description><![CDATA[个人比较偏爱apache,但apache也有不足的地方.比如处理静态请求上.apache会很费劲.nginx也是比较喜欢的一个轻型http服务器.但nginx用fast-cgi跑php也有不足.所以我做了组合,前端跑nginx,后端跑apache.运行了一段时间之后.发现真的不错.所以就一直推荐周遭的朋友这样用.这些日子折腾了好久.终于完成了在Directadmin面板基础上安装nginx的自动安装脚本.这次更新的与前段时间发布的教程不同.这次将nginx真正放到了前端.静态资源完全由nginx处理.后端的apache处理的请求仅限于动态.真正做到动静分离.这样就可以负载更多的访问了. 另外给每个虚拟主机设置了缓存及更完善的防盗链支持. 安装我写了一个脚本.下载后执行就可以了(仅限于centos系统).但是有一个前提:必须在全新安装directadmin面板的机器上安装,这是个已知问题. 安装方法: wget http://icodex.org/dl/directadmin/install.sh chmod 755 install.sh ./install.sh 卸载方法: wget http://icodex.org/dl/directadmin/uninstall.sh chmod 755 uninstall.sh ./uninstall.sh 如果有任何建议或疑问,请发邮件给我(admin@evlit.com) 谢谢! Related Posts给DirectAdmin面板增加nginx前端 (2)nginx + apache (0)[更新]nginx 自动安装脚本 For cPanel (28)nginx文件类型错误解析漏洞 (0)CentOS 适用的第三方yum更新源 (4)]]></description> <content:encoded><![CDATA[<p>个人比较偏爱apache,但apache也有不足的地方.比如处理静态请求上.apache会很费劲.nginx也是比较喜欢的一个轻型http服务器.但nginx用fast-cgi跑php也有不足.所以我做了组合,前端跑nginx,后端跑apache.运行了一段时间之后.发现真的不错.所以就一直推荐周遭的朋友这样用.这些日子折腾了好久.终于完成了在Directadmin面板基础上安装nginx的自动安装脚本.这次更新的与前段时间发布的<a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/">教程</a>不同.这次将nginx真正放到了前端.静态资源完全由nginx处理.后端的apache处理的请求仅限于动态.真正做到动静分离.这样就可以负载更多的访问了.</p><p>另外给每个虚拟主机设置了缓存及更完善的防盗链支持.</p><p>安装我写了一个脚本.下载后执行就可以了(<span style="color: #ff0000;">仅限于centos系统</span>).但是有一个前提:<span style="color: #ff0000;">必须在全新安装directadmin面板的机器上安装</span>,这是个已知问题.</p><p>安装方法:<span id="more-663"></span></p><p><code>wget http://icodex.org/dl/directadmin/install.sh<br /> chmod <span style="color: #ff0000;">755</span> install.sh<br /> ./install.sh</code></p><p>卸载方法:</p><p><code>wget http://icodex.org/dl/directadmin/uninstall.sh<br /> chmod <span style="color: #ff0000;">755</span> uninstall.sh<br /> ./uninstall.sh</code></p><p>如果有任何建议或疑问,请发邮件给我(admin@evlit.com) 谢谢!</p><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/" title="给DirectAdmin面板增加nginx前端">给DirectAdmin面板增加nginx前端</a> (2)</li><li><a href="http://icodex.org/2010/03/nginx-apache/" title="nginx + apache">nginx + apache</a> (0)</li><li><a href="http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/" title="[更新]nginx 自动安装脚本 For cPanel">[更新]nginx 自动安装脚本 For cPanel</a> (28)</li><li><a href="http://icodex.org/2010/05/nginx-0day-by-80sec/" title="nginx文件类型错误解析漏洞">nginx文件类型错误解析漏洞</a> (0)</li><li><a href="http://icodex.org/2010/03/centos-%e9%80%82%e7%94%a8%e7%9a%84%e7%ac%ac%e4%b8%89%e6%96%b9yum%e6%9b%b4%e6%96%b0%e6%ba%90/" title="CentOS 适用的第三方yum更新源">CentOS 适用的第三方yum更新源</a> (4)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/05/directadmin-nginx-automated-installer/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>nginx文件类型错误解析漏洞</title><link>http://icodex.org/2010/05/nginx-0day-by-80sec/</link> <comments>http://icodex.org/2010/05/nginx-0day-by-80sec/#comments</comments> <pubDate>Fri, 21 May 2010 01:23:46 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[0day]]></category> <category><![CDATA[nginx]]></category><guid isPermaLink="false">http://icodex.org/?p=658</guid> <description><![CDATA[漏洞介绍：nginx是一款高性能的web服务器，使用非常广泛，其不仅经常被用作反向代理，也可以非常好的支持PHP的运行。80sec发现 其中存在一个较为严重的安全问题，默认情况下可能导致服务器错误的将任何类型的文件以PHP的方式进行解析，这将导致严重的安全问题，使得恶意的攻击者可 能攻陷支持php的nginx服务器。 漏洞分析：nginx默认以cgi的方式支持php的运行，譬如在配置文件当中可以 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } 的方式支持对php的解析，location对请求进行选择的时候会使用URI环境变量进行选择，其中传递到后端Fastcgi的关键变量 SCRIPT_FILENAME由nginx生成的$fastcgi_script_name决定，而通过分析可以看 到$fastcgi_script_name是直接由URI环境变量控制的，这里就是产生问题的点。而为了较好的支持PATH_INFO的提取，在PHP 的配置选项里存在cgi.fix_pathinfo选项，其目的是为了从SCRIPT_FILENAME里取出真正的脚本名。 那么假设存在一个http://www.80sec.com/80sec.jpg，我们以如下的方式去访问 http://www.80sec.com/80sec.jpg/80sec.php 将会得到一个URI /80sec.jpg/80sec.php 经过location指令，该请求将会交给后端的fastcgi处理，nginx为其设置环境变量SCRIPT_FILENAME，内容为 /scripts/80sec.jpg/80sec.php 而在其他的webserver如lighttpd当中，我们发现其中的SCRIPT_FILENAME被正确的设置为 /scripts/80sec.jpg 所以不存在此问题。 后端的fastcgi在接受到该选项时，会根据fix_pathinfo配置决定是否对SCRIPT_FILENAME进行额外的处理，一般情况下如果不 对fix_pathinfo进行设置将影响使用PATH_INFO进行路由选择的应用，所以该选项一般配置开启。Php通过该选项之后将查找其中真正的脚 本文件名字，查找的方式也是查看文件是否存在，这个时候将分离出SCRIPT_FILENAME和PATH_INFO分别为 /scripts/80sec.jpg和80sec.php 最后，以/scripts/80sec.jpg作为此次请求需要执行的脚本，攻击者就可以实现让nginx以php来解析任何类型的文件了。 POC：访问一个nginx来支持php的站点，在一个任何资源的文件如robots.txt后面加上/80sec.php，这个时候你可以看到如下的区别： 访问http://www.80sec.com/robots.txt HTTP/1.1 200 OK Server: nginx/0.6.32 Date: Thu, 20 May 2010 10:05:30 GMT Content-Type: text/plain Content-Length: [...]]]></description> <content:encoded><![CDATA[<p>漏洞介绍：nginx是一款高性能的web服务器，使用非常广泛，其不仅经常被用作反向代理，也可以非常好的支持PHP的运行。80sec发现 其中存在一个较为严重的安全问题，默认情况下可能导致服务器错误的将任何类型的文件以PHP的方式进行解析，这将导致严重的安全问题，使得恶意的攻击者可 能攻陷支持php的nginx服务器。</p><p>漏洞分析：nginx默认以cgi的方式支持php的运行，譬如在配置文件当中可以</p><p><code>location ~ \.php$ {<br /> root           html;<br /> fastcgi_pass   127.0.0.1:9000;<br /> fastcgi_index  index.php;<br /> fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;<br /> include        fastcgi_params;<br /> }</code></p><p>的方式支持对php的解析，location对请求进行选择的时候会使用URI环境变量进行选择，其中传递到后端Fastcgi的关键变量 SCRIPT_FILENAME由nginx生成的$fastcgi_script_name决定，而通过分析可以看 到$fastcgi_script_name是直接由URI环境变量控制的，这里就是产生问题的点。而为了较好的支持PATH_INFO的提取，在PHP 的配置选项里存在cgi.fix_pathinfo选项，其目的是为了从SCRIPT_FILENAME里取出真正的脚本名。<span id="more-658"></span></p><p>那么假设存在一个http://www.80sec.com/80sec.jpg，我们以如下的方式去访问 http://www.80sec.com/80sec.jpg/80sec.php 将会得到一个URI</p><p><code>/80sec.jpg/80sec.php</code></p><p>经过location指令，该请求将会交给后端的fastcgi处理，nginx为其设置环境变量SCRIPT_FILENAME，内容为</p><p><code>/scripts/80sec.jpg/80sec.php</code></p><p>而在其他的webserver如lighttpd当中，我们发现其中的SCRIPT_FILENAME被正确的设置为</p><p><code>/scripts/80sec.jpg</code></p><p>所以不存在此问题。</p><p>后端的fastcgi在接受到该选项时，会根据fix_pathinfo配置决定是否对SCRIPT_FILENAME进行额外的处理，一般情况下如果不 对fix_pathinfo进行设置将影响使用PATH_INFO进行路由选择的应用，所以该选项一般配置开启。Php通过该选项之后将查找其中真正的脚 本文件名字，查找的方式也是查看文件是否存在，这个时候将分离出SCRIPT_FILENAME和PATH_INFO分别为</p><p><code>/scripts/80sec.jpg和80sec.php</code></p><p>最后，以/scripts/80sec.jpg作为此次请求需要执行的脚本，攻击者就可以实现让nginx以php来解析任何类型的文件了。</p><p>POC：访问一个nginx来支持php的站点，在一个任何资源的文件如robots.txt后面加上/80sec.php，这个时候你可以看到如下的区别：</p><p>访问http://www.80sec.com/robots.txt</p><p><code>HTTP/1.1 200 OK<br /> Server: nginx/0.6.32<br /> Date: Thu, 20 May 2010 10:05:30 GMT<br /> Content-Type: text/plain<br /> Content-Length: 18<br /> Last-Modified: Thu, 20 May 2010 06:26:34 GMT<br /> Connection: keep-alive<br /> Keep-Alive: timeout=20<br /> Accept-Ranges: bytes</code></p><p>访问访问http://www.80sec.com/robots.txt/80sec.php</p><p><code>HTTP/1.1 200 OK<br /> Server: nginx/0.6.32<br /> Date: Thu, 20 May 2010 10:06:49 GMT<br /> Content-Type: text/html<br /> Transfer-Encoding: chunked<br /> Connection: keep-alive<br /> Keep-Alive: timeout=20<br /> X-Powered-By: PHP/5.2.6</code></p><p>其中的Content-Type的变化说明了后端负责解析的变化，该站点就可能存在漏洞。</p><p>漏洞厂商：http://www.nginx.org</p><p>解决方案：</p><p>我们已经尝试联系官方，但是此前你可以通过以下的方式来减少损失</p><p><code>关闭cgi.fix_pathinfo为0</code></p><p>或者</p><p><code>if  ( $fastcgi_script_name ~ \..*\/.*php )  {<br /> return 403;<br /> }</code></p><p>PS: 鸣谢<a href="http://www.laruence.com/2010/05/20/1495.html">laruence</a>大 牛在分析过程中给的帮助</p><p>转载自: nginx文件类型错误解析漏洞:http://www.80sec.com/nginx-securit.html</p><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/" title="适用于Directadmin面板的Nginx自动安装脚本">适用于Directadmin面板的Nginx自动安装脚本</a> (2)</li><li><a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/" title="给DirectAdmin面板增加nginx前端">给DirectAdmin面板增加nginx前端</a> (2)</li><li><a href="http://icodex.org/2010/03/nginx-apache/" title="nginx + apache">nginx + apache</a> (0)</li><li><a href="http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/" title="[更新]nginx 自动安装脚本 For cPanel">[更新]nginx 自动安装脚本 For cPanel</a> (28)</li><li><a href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/" title="为nginx虚拟主机配置startssl免费https证书">为nginx虚拟主机配置startssl免费https证书</a> (0)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/05/nginx-0day-by-80sec/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>给DirectAdmin面板增加nginx前端</title><link>http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/</link> <comments>http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/#comments</comments> <pubDate>Tue, 11 May 2010 04:13:18 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[DirectAdmin]]></category> <category><![CDATA[nginx]]></category><guid isPermaLink="false">http://icodex.org/?p=626</guid> <description><![CDATA[已更新自动安装版本 : http://icodex.org/2010/05/directadmin-nginx-automated-installer/ Related Posts适用于Directadmin面板的Nginx自动安装脚本 (2)nginx + apache (0)[更新]nginx 自动安装脚本 For cPanel (28)nginx文件类型错误解析漏洞 (0)为nginx虚拟主机配置startssl免费https证书 (0)]]></description> <content:encoded><![CDATA[<p><span style="color: #ff0000;">已更新自动安装版本</span> : <a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/">http://icodex.org/2010/05/directadmin-nginx-automated-installer/</a></p><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/" title="适用于Directadmin面板的Nginx自动安装脚本">适用于Directadmin面板的Nginx自动安装脚本</a> (2)</li><li><a href="http://icodex.org/2010/03/nginx-apache/" title="nginx + apache">nginx + apache</a> (0)</li><li><a href="http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/" title="[更新]nginx 自动安装脚本 For cPanel">[更新]nginx 自动安装脚本 For cPanel</a> (28)</li><li><a href="http://icodex.org/2010/05/nginx-0day-by-80sec/" title="nginx文件类型错误解析漏洞">nginx文件类型错误解析漏洞</a> (0)</li><li><a href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/" title="为nginx虚拟主机配置startssl免费https证书">为nginx虚拟主机配置startssl免费https证书</a> (0)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>nginx + apache</title><link>http://icodex.org/2010/03/nginx-apache/</link> <comments>http://icodex.org/2010/03/nginx-apache/#comments</comments> <pubDate>Fri, 12 Mar 2010 03:09:53 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[backend]]></category> <category><![CDATA[nginx]]></category><guid isPermaLink="false">http://icodex.org/?p=238</guid> <description><![CDATA[前后端搭配,nginx在前处理部分静态请求,其他的proxy给后端的apache,详情请移步: 搭建前后端web生产环境 Related Posts适用于Directadmin面板的Nginx自动安装脚本 (2)给DirectAdmin面板增加nginx前端 (2)[更新]nginx 自动安装脚本 For cPanel (28)nginx文件类型错误解析漏洞 (0)为nginx虚拟主机配置startssl免费https证书 (0)]]></description> <content:encoded><![CDATA[<p>前后端搭配,nginx在前处理部分静态请求,其他的proxy给后端的apache,详情请移步:</p><h2><a title="Permanent Link: 搭建前后端web生产环境" rel="bookmark" href="http://icodex.org/2010/03/nginx-apache-guide/">搭建前后端web生产环境</a></h2><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/" title="适用于Directadmin面板的Nginx自动安装脚本">适用于Directadmin面板的Nginx自动安装脚本</a> (2)</li><li><a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/" title="给DirectAdmin面板增加nginx前端">给DirectAdmin面板增加nginx前端</a> (2)</li><li><a href="http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/" title="[更新]nginx 自动安装脚本 For cPanel">[更新]nginx 自动安装脚本 For cPanel</a> (28)</li><li><a href="http://icodex.org/2010/05/nginx-0day-by-80sec/" title="nginx文件类型错误解析漏洞">nginx文件类型错误解析漏洞</a> (0)</li><li><a href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/" title="为nginx虚拟主机配置startssl免费https证书">为nginx虚拟主机配置startssl免费https证书</a> (0)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/03/nginx-apache/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>[更新]nginx 自动安装脚本 For cPanel</title><link>http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/</link> <comments>http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/#comments</comments> <pubDate>Mon, 22 Feb 2010 19:54:26 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[cPanel]]></category> <category><![CDATA[Hack]]></category> <category><![CDATA[nginx]]></category><guid isPermaLink="false">http://icodex.org/?p=76</guid> <description><![CDATA[版本更新啦！现在安装包支持proxy_cache模块，支持密码保护目录、自定义错误页面等。并且支持wildcard泛域名解析！请更新新版本的nginx前端。先卸载旧版本，再安装新版本。方法不变。如果你有任何意见或建议，请与我联系。 为cPanel主机添加nginx服务器软件,这样可以让nginx跑在前端处理静态文件,并且加装nginx后的资源消耗比单纯跑apache少很多.在找cPanel hack的资料的时候,刚好看到cPanel官方论坛上的一个牛人写的一个安装脚本,仔细拜读了一遍代码之后,决定在自己的cPanel服务器上安装.在使用过程中也渐渐发现了一些可以优化.可以增加的特性,主要是nginx上的一些新特性,籍由这些特性,完成了平时似乎不能完成的功能,例如在高并发的机器上实现的服务器端的缓存功能,以及nginx作为前端的时候使用.htaccess进行目录保护.这些特性都大大方便了我们的使用. 这里引用cPanel Forums上的帖子.作者blargman写了一个专门为cPanel打造的nginx自动安装脚本. Evidently I don't know hot to post in the right forum. This is an automated nginx installer for cpanel. Integrates so that domain adding/removal is all done automatically. Some people had asked for cpanel support. In lieu of that, this does pretty much everything I can think of that they [...]]]></description> <content:encoded><![CDATA[<p><span style="color: #ff0000;">版本更新啦！现在安装包支持proxy_cache模块，支持密码保护目录、自定义错误页面等。并且支持wildcard泛域名解析！请更新新版本的nginx前端。先卸载旧版本，再安装新版本。方法不变。如果你有任何意见或建议，请与我联系。</span></p><p>为cPanel主机添加nginx服务器软件,这样可以让nginx跑在前端处理静态文件,并且加装nginx后的资源消耗比单纯跑apache少很多.在找cPanel hack的资料的时候,刚好看到cPanel官方论坛上的一个牛人写的一个安装脚本,仔细拜读了一遍代码之后,决定在自己的cPanel服务器上安装.在使用过程中也渐渐发现了一些可以优化.可以增加的特性,主要是nginx上的一些新特性,籍由这些特性,完成了平时似乎不能完成的功能,例如在高并发的机器上实现的服务器端的缓存功能,以及nginx作为前端的时候使用.htaccess进行目录保护.这些特性都大大方便了我们的使用.</p><p>这里引用cPanel Forums上的帖子.作者<a rel="nofollow" href="http://forums.cpanel.net/members/blargman/">blargman</a>写了一个专门为cPanel打造的nginx自动安装脚本.</p><blockquote><p>Evidently I don't know hot to post in the right forum.</p><p>This is an automated nginx installer for cpanel. Integrates so that  domain adding/removal is all done automatically.<br /> Some people had asked for cpanel support. In lieu of that, this does  pretty much everything I can think of that they would do. It creates a  vhost for each domain/addon/subdomain and serves up static content.</p><p>Let me know if you have any thoughts/questions or better yet  suggestions.<br /> <a onclick="pageTracker._trackPageview  ('/out/http_blargman_com_public_tar');" rel="nofollow" href="http://blargman.com/public.tar" target="_blank">http://blargman.com/public.tar</a></p></blockquote><p>以上是作者原文,原文地址:<a href="http://forums.cpanel.net/f5/nginx-automated-installer-148109.html">点击这里</a>.</p><p><span id="more-76"></span>安装方法很简单(建议做好备份),如下:</p><blockquote><p><code>cd /usr/local/src<br /> wget http://blargman.com/public.tar<br /> tar xf public.tar<br /> cd publicnginx<br /> ./nginxinstaller install</code></p></blockquote><p>安装好之后,重启nginx,执行命令:<strong>/etc/init.d/nginx restart</strong>.Nginx的配置文件均在<strong>/etc/nginx</strong>当中,各用户绑定的域名(附加域,子域等)均在<strong>/etc/nginx/vhosts</strong></p><p>卸载:</p><p><code>进入publicnginx目录后执行</code><code>./nginxinstaller uninstall.</code></p><p>-------------------------------------------------------------------------------------------------------------------------------------</p><p>我在作者编写代码的基础上增加了缓存功能,以及更多功能上的支持,例如防盗链,自定义错误页面等.为方便大家使用.做出的修改我已经打包成修改版的安装包.</p><p>有朋友问到我的版本和论坛里原版本的差别是在哪.我的版本解决了哪些问题.这是大部分用户的问题,这里集中进行回答.</p><p>1.完善的目录密码保护功能 -- 这个在原作者的安装包里面,并不能做到,原因在于没有对401状态码进行判断.<br /> 2.伪静态功能的实现 -- 不管你的是以html结尾的还是以"/" 结尾的URL地址,nginx会提前判断文件系统中是否存在该文件/目录,如果不存在,那么就会匹配到后端的apache.后端的apache根据.htaccess文件的设置,进行页面的展示,前端nginx获取到内容后便进行压缩,然后传递给访客浏览器中.<br /> 3.访问日志准确记录 -- 原作者的安装包中,是nginx与apache共用同个日志文件进行记录.nginx记录静态页面的访问信息,apache记录动态页面访问信息,理论上可行.但在实际使用中,我发现了这个问题.这个问题一个突破口在于对后缀.html匹配的时候,同时查询了前端nginx及后端的apache.这样就造成了日志的重复.另外一个是一些没有匹配到的后缀,前端不仅处理了访客的请求并进行记录,还会向后端发起请求查询.但由于大文件不会很快就传输完毕,因此即便设置了keepalive也无济于事.在我的安装包中,我将后端的用户配置中非加密端口的日志功能取消了,完全由前端的nginx进行记录.<br /> 4.日志切割问题 -- 这个问题来自前面说的第3点修改,如果只是修改了第3点而没有进行这一步,那么就会碰到一个问题:当执行用户访问日志切割并转为统计页面展示给用户看,系统会自动将用户的日志删除,导致这之后的日志访问信息丢失直至下次nginx重启.在对cpanel日志统计进程的跟踪后,找出/usr/local/cpanel/bin/safeapacherestart这行.这行的作用是让日志切割后的apache可以安全的重新启动.解决办法就是一改作者重启nginx的方式,我将重启nginx的信息加入apache的重启命令中,以后只需要对apache进行命令操作就可以了.<br /> 5.泛域名解析 -- cpanel支持泛域名解析,而且在作为主机商而言,泛域名也是一个特色,需要用起来.但是作者的版本以及我之前修改的版本中,并没有对这块进行支持,一旦客户绑定了泛域名,就会使nginx无法启动,全部用户的网站受影响.那么这次的更新就包含了这个功能.<br /> 6.基于proxy_cache的缓存系统 -- 这个是我添加的,为可选功能.删除缓存的方法可以遵循squidclient的方式进行.<strong>不带缓存的安装版本 http://icodex.org/public_nocache.tar</strong></p><p>另外需要注意的,网友们提到的一个是重启nginx后的那一串提示.这个警告信息是提示你主机名存在错误,不影响使用.</p><p>安装方法与作者原版一样.请执行如下安装!</p><p><code>cd /usr/local/src<br /> wget http://icodex.org/public.tar<br /> tar xf public.tar<br /> cd publicnginx<br /> ./nginxinstaller install</code></p><p><span style="color: #ff0000;">注意:如果之前安装了作者原版本的nginx,请先卸载后再执行安装.</span></p><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/" title="适用于Directadmin面板的Nginx自动安装脚本">适用于Directadmin面板的Nginx自动安装脚本</a> (2)</li><li><a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/" title="给DirectAdmin面板增加nginx前端">给DirectAdmin面板增加nginx前端</a> (2)</li><li><a href="http://icodex.org/2010/03/nginx-apache/" title="nginx + apache">nginx + apache</a> (0)</li><li><a href="http://icodex.org/2010/05/nginx-0day-by-80sec/" title="nginx文件类型错误解析漏洞">nginx文件类型错误解析漏洞</a> (0)</li><li><a href="http://icodex.org/2010/02/vps%e5%90%88%e7%a7%9f%e7%ac%ac%e4%b8%80%e6%9c%9f-knownhost/" title="VPS合租第一期:Knownhost">VPS合租第一期:Knownhost</a> (6)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/feed/</wfw:commentRss> <slash:comments>28</slash:comments> </item> <item><title>为nginx虚拟主机配置startssl免费https证书</title><link>http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/</link> <comments>http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/#comments</comments> <pubDate>Mon, 08 Feb 2010 05:12:27 +0000</pubDate> <dc:creator>admin</dc:creator> <category><![CDATA[codex]]></category> <category><![CDATA[https]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[ssl]]></category><guid isPermaLink="false">http://icodex.org/?p=14</guid> <description><![CDATA[StartSSL是一个免费颁发SSL证书的机构,被多数有 Linux 背景的软件支持(以Mozilla的Firefox和Thunderbird为首).以前IE是没有StartSSL的根证书的,以至于一段时间IE都会将使用StartSSL证书的网站列为不受信任的网站. 但是现在情况有所改观了,今年9月份,StartCom公司出现在Windows根证书认证程序厂商更新当中,因此StartSSL证书在IE平台上已经可以正常使用的.另外Chrome,苹果Safari浏览器都可以正常识别StartSSL颁发的证书.但是Opera浏览器仍然不能支持. 为 nginx虚拟主机配置startssl证书 前提条件:独立IP.一台Linux机器.Startssl账户申请这里就不说明了.申请很简单,验证域名所有权也很简单.这里就做证书的配置. 我们先为域名生成证书请求文件和密钥.需要生成2048位加密的证书请求.以icodex.org为例,执行命令: openssl req -new -newkey rsa:2048 -nodes -out icodex.csr -keyout icodex.key 执行之后在/etc/nginx/certs目录中就有icodex.csr. 执行cat icodex.csr查看里面的内容并复制: 然后将复制的粘贴到startssl后 台,这里每一步都进行截图: 第一步: 第二步: 第三步: 第四步: 第五步: 第六步: 第七步: 第八步: 最后一步注意要先将这段代码保存为icodex.crt 放在与icodex.csr icodex.key同个目录. 然后配置nginx,直接丢配置上来. server { listen       443; listen       80; server_name  os.icodex.org; root   /home/icodex/os/public_html; index index.html index.htm index.php; access_log  /var/log/nginx/os.icodex.org-access.log  access; ssl    on; ssl_certificate    [...]]]></description> <content:encoded><![CDATA[<p><a href="http://www.startssl.com/">StartSSL</a>是一个免费颁发SSL证书的机构,被多数有 Linux 背景的软件支持(以Mozilla的Firefox和Thunderbird为首).以前IE是没有StartSSL的根证书的,以至于一段时间IE都会将使用StartSSL证书的网站列为不受信任的网站.</p><p>但是现在情况有所改观了,今年9月份,StartCom公司出现在Windows根证书认证程序厂商更新当中,因此StartSSL证书在IE平台上已经可以正常使用的.另外Chrome,苹果Safari浏览器都可以正常识别StartSSL颁发的证书.但是Opera浏览器仍然不能支持.<span id="more-14"></span></p><h2>为 nginx虚拟主机配置startssl证书</h2><p>前提条件:独立IP.一台Linux机器.Startssl账户申请这里就不说明了.申请很简单,验证域名所有权也很简单.这里就做证书的配置.</p><p>我们先为域名生成证书请求文件和密钥.需要生成2048位加密的证书请求.以icodex.org为例,执行命令:</p><blockquote><p>openssl req -new -newkey rsa:2048 -nodes -out icodex.csr -keyout  icodex.key</p></blockquote><p><a rel="attachment wp-att-15" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/1/"><img class="alignnone size-medium wp-image-15" title="1" src="http://cdn.icodex.org/wp-content/uploads/2010/02/1-400x283.jpg" alt="" width="400" height="283" /></a></p><p>执行之后在/etc/nginx/certs目录中就有icodex.csr. 执行cat icodex.csr查看里面的内容并复制:</p><p><a rel="attachment wp-att-16" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/2/"><img class="alignnone size-medium wp-image-16" title="2" src="http://cdn.icodex.org/wp-content/uploads/2010/02/2-400x245.jpg" alt="" width="400" height="245" /></a></p><p>然后将复制的粘贴到startssl后 台,这里每一步都进行截图:</p><p>第一步:<br /> <a rel="attachment wp-att-17" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/3/"><img class="alignnone size-medium wp-image-17" title="3" src="http://cdn.icodex.org/wp-content/uploads/2010/02/3-400x172.jpg" alt="" width="400" height="172" /></a></p><p>第二步:<br /> <a rel="attachment wp-att-18" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/4/"><img class="alignnone size-medium wp-image-18" title="4" src="http://cdn.icodex.org/wp-content/uploads/2010/02/4-400x195.jpg" alt="" width="400" height="195" /></a></p><p>第三步:<br /> <a rel="attachment wp-att-19" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/5/"><img class="alignnone size-medium wp-image-19" title="5" src="http://cdn.icodex.org/wp-content/uploads/2010/02/5-400x240.jpg" alt="" width="400" height="240" /></a></p><p>第四步:<br /> <a rel="attachment wp-att-20" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/6/"><img class="alignnone size-medium wp-image-20" title="6" src="http://cdn.icodex.org/wp-content/uploads/2010/02/6-400x171.jpg" alt="" width="400" height="171" /></a></p><p>第五步:<br /> <a rel="attachment wp-att-21" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/7/"><img class="alignnone size-medium wp-image-21" title="7" src="http://cdn.icodex.org/wp-content/uploads/2010/02/7-400x156.jpg" alt="" width="400" height="156" /></a></p><p>第六步:<br /> <a rel="attachment wp-att-22" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/8/"><img class="alignnone size-medium wp-image-22" title="8" src="http://cdn.icodex.org/wp-content/uploads/2010/02/8-399x195.jpg" alt="" width="399" height="195" /></a></p><p>第七步:<br /> <a rel="attachment wp-att-23" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/9/"><img class="alignnone size-medium wp-image-23" title="9" src="http://cdn.icodex.org/wp-content/uploads/2010/02/9-399x158.jpg" alt="" width="399" height="158" /></a></p><p>第八步:<br /> <a rel="attachment wp-att-24" href="http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/attachment/10/"><img class="alignnone size-medium wp-image-24" title="10" src="http://cdn.icodex.org/wp-content/uploads/2010/02/10-400x219.jpg" alt="" width="400" height="219" /></a></p><p>最后一步注意要先将这段代码保存为icodex.crt 放在与icodex.csr icodex.key同个目录.</p><p>然后配置nginx,直接丢配置上来.</p><blockquote><p>server {<br /> listen       443;<br /> listen       80;<br /> server_name  os.icodex.org;<br /> root   /home/icodex/os/public_html;<br /> index index.html index.htm index.php;<br /> access_log  /var/log/nginx/os.icodex.org-access.log   access;</p><p>ssl    on;<br /> ssl_certificate    /etc/nginx/certs/icodex.crt;<br /> ssl_certificate_key     /etc/nginx/certs/icodex.key;<br /> ssl_session_timeout 5m;</p><p>ssl_protocols SSLv2 SSLv3 TLSv1;<br /> ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;<br /> ssl_prefer_server_ciphers   on;</p><p>location ~* ^.+\.(js|css|jpg|jpeg|gif|png|ico|bmp|swf)$ {<br /> expires      7d;<br /> }</p><p># pass the PHP scripts to FastCGI server<br /> #<br /> location ~ .*\.php$ {<br /> fastcgi_index  index.php;<br /> fastcgi_pass    127.0.0.1:9000;<br /> include        fastcgi_params;<br /> <strong>fastcgi_param   HTTPS on;</strong><br /> }<br /> }</p></blockquote><p>最后重启nginx.完毕...</p><p>另外,昨日与Showfom(此君 域名我妒忌)聊天的时候谈到火狐中文版验证ssl时提示ssl不受信任的问题,这应该是根证书的问题,后来测试,果然解决了.我们知道在apache有  SSLCertificateChainFile用来指定CA根证书位置,虽然nginx没有这个字段来指定,但是在nginx和lighttpd中是可  以将CA根证书与我们自己的证书合并使用的(声明来源:Sudone).步骤如下:</p><p>我们先到startssl下载 CA根证书,地址:http://cert.startssl.com/certs /,然后进入我们的证书保存位置,注意,操作前记得备份原证书文件.</p><blockquote><p>cd /etc/nginx/certs/<br /> cp  icodex.crt  icodex.crt.bak<br /> wget http://www.startssl.com/certs/ca.pem<br /> cat ca.pem &gt;&gt; icodex.crt</p></blockquote><p>最后重启nginx即可.</p><h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://icodex.org/2010/05/directadmin-nginx-automated-installer/" title="适用于Directadmin面板的Nginx自动安装脚本">适用于Directadmin面板的Nginx自动安装脚本</a> (2)</li><li><a href="http://icodex.org/2010/05/nginx-0day-by-80sec/" title="nginx文件类型错误解析漏洞">nginx文件类型错误解析漏洞</a> (0)</li><li><a href="http://icodex.org/2010/05/%e7%bb%99directadmin%e9%9d%a2%e6%9d%bf%e5%a2%9e%e5%8a%a0nginx%e5%89%8d%e7%ab%af/" title="给DirectAdmin面板增加nginx前端">给DirectAdmin面板增加nginx前端</a> (2)</li><li><a href="http://icodex.org/2010/03/nginx-apache/" title="nginx + apache">nginx + apache</a> (0)</li><li><a href="http://icodex.org/2010/02/nginx%e8%87%aa%e5%8a%a8%e5%ae%89%e8%a3%85%e8%84%9a%e6%9c%ac-for-cpanel/" title="[更新]nginx 自动安装脚本 For cPanel">[更新]nginx 自动安装脚本 For cPanel</a> (28)</li></ul>]]></content:encoded> <wfw:commentRss>http://icodex.org/2010/02/%e4%b8%banginx%e8%99%9a%e6%8b%9f%e4%b8%bb%e6%9c%ba%e9%85%8d%e7%bd%aestartssl%e5%85%8d%e8%b4%b9https%e8%af%81%e4%b9%a6/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced) (user agent is rejected)
Database Caching 30/49 queries in 0.043 seconds using disk
Object Caching 1123/1136 objects using disk
Content Delivery Network via cdn.icodex.org

Served from: icodex.org @ 2010-09-09 18:52:46 -->