利用命名管道实现nginx日志的多时区

一个应用场景需要在同一个机器上产生不同时区的日志。

方法:
建立命名管道,将nginx的日志写到命名管道,然后写个脚本接受命名管道的数据并且将时间转换到对应时区之后再输出到新的日志文件。

需要注意的地方就是要先运行脚本接受命名管道的数据,不然nginx在进行reload的操作的时候会卡住,over。

另外提供一个刚找到的好东西:http://trac.nchc.org.tw/cloud/,看台湾的技术文档实在是件很惬意的事情。

php : variables_order

The presence and order of variables listed in this array is defined according to the PHP variables_order configuration directive.

php.ini : variables_order

Sets the order of the EGPCS (Environment, Get, Post, Cookie, and Server) variable parsing. For example, if variables_order is set to “SP” then PHP will create the superglobals $_SERVER and $_POST, but not create $_ENV, $_GET, and $_COOKIE. Setting to “” means no superglobals will be set.

一个RewriteCond应用到多个RewriteRule

默认情况下 RewriteCond 只应用到 其紧跟着的 RewriteRule。

手册里有个 RewriteCond backreferences :

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond

貌似可以实现一个RewriteCond应用到多个RewriteRule,不过看了一下不知道怎么用。

Ask Google大神找到了一个老外的解决方案:

http://my.galagzee.com/2009/02/11/mod_rewrite-one-rewritecond-to-many-rewriterules/

RewriteCond %{REQUEST_URI} !^/(pattern1|pattern2|pattern3)(/[0-9]+|/P[0-9]+|)[/]?$ [NC]
RewriteRule . – [S=3]
RewriteRule ^/([^/]*)[/]?$ /index.php/site_embeds/department/$1/X [L]
RewriteRule ^/([^/]*)/([0-9]+)[/]?$ /index.php/site_embeds/article/$2/$1 [L]
RewriteRule ^/([^/]*)/P([0-9]+)[/]?$ /index.php/site_embeds/department_archive/P$2/$1 [L]

RewriteRule 有个 S 参数,可以用来跳过其后续一定数量的规则。
然后对RewriteCond的条件取反,就可以实现了。

CloudFront & edgecast

给Redmine做了一个CDN中转,

CloudFront中国电信是访问到日本的节点,速度比较好。
edgecast访问到美国的节点,速度还可以接受,比较稳定。

不过悲催的是CloudFront不支持POST方法,在POST表单的时候直接返回403错误。