Monthly Archive九月 2008
Web Server/Apache/Nginx & 技术 22 Sep 2008 03:09 pm
nginx下j_space人才系统rewrite
系统设置为“完整格式” 如: http://www.wjob.com.cn/index.php/index.html
[code]
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~* ^/index.php/
{
rewrite ^/index.php/(.*) /index.php?$1 break;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
[/code]
linux 维护优化 & 技术 22 Sep 2008 02:09 pm
awstats按日产生统计报表
修改wwwroot/cgi-bin/awstats.pl
7851行增加日期下拉框
[code]
print “<select class=\”aws_formfield\” name=\”day\”>\n”;
foreach (1..31) {
my $dayix=sprintf(”%02s”,$_);
print “<option”.(”$DayRequired” eq “$dayix”?” selected=\”true\”":”").” value=\”$dayix\”>$dayix</option>\n”;
}
print “</select>\n”;
[/code]
7871行增加databasebreak参数
[code]
if ($DatabaseBreak) { print “<input type=\”hidden\” name=\”DatabaseBreak\” value=\”$DatabaseBreak\” />\n”; }
[/code]
命令行统计增加:-databasebreak=day
查看报表时地址栏需增加:&databasebreak=day&day=DD
以下为查看页代码
[code]
<script>
var d = new Date();
d.setTime(d.setDate(d.getDate()-1));
var day=d.getDate();
var srv = new Array();
srv[0]=’www.c1gstudio.com’;
srv[1]=’bbs.c1gstudio.com’;
srv[2]=’blog.c1gstudio.com’;
srv[3]=’admin.c1gstudio.com’;
for (var i=0;i<srv.length ;i++ )
{
document.writeln(’<p><a href=”http://admin.c1gstudio.com/cgi-bin/awstats.pl?config=’+srv[i]+’&databasebreak=day&day=’+day+’” target=”_blank”>http://admin.c1gstudio.com/cgi-bin/awstats.pl?config=’+srv[i]+’</a></p>’);
}
document.writeln(’<hr>’);
[/code]
参考:
http://blogger.org.cn/blog/more.asp?name=chenjiejacky&id=20464
http://www.chedong.com/blog/archives/001293.html#more
Web Server/Apache/Nginx & 技术 18 Sep 2008 01:44 pm
apache log中的 Apache (internal dummy connection)
#tail logs/access_log
::1 - - [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0″ 200 843 “-” “Apache (internal dummy connection)”
::1 - - [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0″ 200 843 “-” “Apache (internal dummy connection)”
::1 - - [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0″ 200 843 “-” “Apache (internal dummy connection)”
::1 - - [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0″ 200 843 “-” “Apache (internal dummy connection)”
::1 - - [18/Sep/2008:13:56:34 +0800] “GET / HTTP/1.0″ 200 843 “-” “Apache (internal dummy connection)”
修改httpd.conf
SetEnvIf Remote_Addr “::1″ dontlog
CustomLog logs/access_log combined env=!dontlog
Tools & 其它 16 Sep 2008 03:35 pm
editplus小技巧:正则替换 html中的标签
举例有html内容如下
<table class=”data”>
<tr class=”abc”>
<td class=”row1″>abc</td>
<td width=”200″ class=”row2″>abc</td>
<td class=”row3″ style=”padding:5px” >abc</td>
</tr>
</table>
需将<td >中的内容清空.
用editplus打开,shift+H.
查找内容:<td[^>]*
替换内容:<td
勾上使用正则表达式
解释:查找以“<td”开始的字符,下一个或第N个字符不为”>”的行
也可以这样
查找内容:<td(.*)>(.*)</td>
替换内容:<td>\2</td>
解释:查找以“<td”开始,以</td>结束,中间以”>”分成两段,最出只输出第二段。
Web Server/Apache/Nginx & 技术 16 Sep 2008 02:45 pm
nginx 目录自动加斜线”/”
默认配置当你访问http://abc.example.com/dir 时不会加”/”
常见做法
[code]
if (-d $request_filename){
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}
[/code]
更佳的替代方法
optimize_server_names off;#优化服务器名称:关
server_name_in_redirect off;#服务器名称重定向:关
http://wiki.codemongers.com/NginxHttpCoreModule#optimize_server_names
Web Server/Apache/Nginx 16 Sep 2008 01:29 pm
nginx 使用ip和密码保护你的目录
apache限制ip方法
<virtualhost 222.222.222.222>
documentroot “/opt/htdocs/www/”
servername admin.c1gstudio.com
<Directory “/opt/htdocs/www/”>
Options IncludesNoExec FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.1 222.222.222.222 111.111.111.111
</Directory>
</virtualhost>
使用ngx_http_access_module限制ip访问
官方示例
http://wiki.codemongers.com/NginxHttpAccessModule#allow
[code]
location / {
deny 192.168.1.1;
allow 192.168.1.0/24;
allow 10.1.1.0/16;
deny all;
}
[/code]
改成自已的
[code]
location / {
allow 127.0.0.1;
allow 222.222.222.222;#服务器ip
allow 111.111.111.111;#自已电脑的ip
deny all;
}
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ ^/cgi-bin/.*\.pl$ {
auth_basic “Restricted”;
auth_basic_user_file htpasswd;
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
include awstats.conf;
}
location ^~ /nginx {
stub_status on;
access_log off;
auth_basic “NginxStatus”;
auth_basic_user_file htpasswd;
}
location ~ ^/memcached {
access_log off;
auth_basic “NginxStatus”;
auth_basic_user_file htpasswd;
}
[/code]
结果:测试下来非定义的ip还是可以访问。
再修改下正则
[code]
location ^~ / {
allow 127.0.0.1;
allow 222.222.222.222;#服务器ip
allow 111.111.111.111;#自已电脑的ip
deny all;
}
[/code]
结果:非定义的是ip不可以访问了,但php变明文显示,perl是404。
|
|
|
| 你可以看看 nginx 的文档里面关于 location 的说明。它的匹配方式是 正则表达式 优先级比较高。 就是说,你的 PHP 解析用的是 正则表达式进行匹配,而你要限制的目录不是用正则表达式,所以,就算是要限制的目录,因为PHP还是能被匹配到,所以,还是解析PHP了。所以,如果想解决的话,可能需要把目录也写成正则匹配,而且要放在PHP的前面,否则就会先匹配PHP
|
|
satisfy_any on;
http://www.freebsdchina.org/forum/viewtopic.php?t=42141
使用多级目录将保护目录放在根中
[code]
location / {
#allow 127.0.0.1;
#allow 222.222.222.222;#服务器ip
allow 111.111.111.111;#自已电脑的ip
deny all;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ ^/cgi-bin/.*\.pl$ {
auth_basic “Restricted”;
auth_basic_user_file htpasswd;
gzip off; #gzip makes scripts feel slower since they have to complete before getting gzipped
include awstats.conf;
}
location ^~ /nginx {
stub_status on;
access_log off;
auth_basic “NginxStatus”;
auth_basic_user_file htpasswd;
}
location ~ ^/memcached {
access_log off;
auth_basic “NginxStatus”;
auth_basic_user_file htpasswd;
}
}
[/code]
结果:有效
整个域名需禁止访问可以写在server中
server {
listion 80;
server_name admin.c1gstudio.com;
root /opt/htdocs/www;
allow 111.111.111.111;#自已电脑的ip
deny all;
auth_basic “Nginx_Panel”;
auth_basic_user_file htpasswd;
location ~ .*\.php?$
{
….
}
location ^~ /phpmyadmin {
satisfy any;
access_log off;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}
location ^~ /memcached {
satisfy any;
access_log off;
location ~ .*\.php?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
}
}
参考:http://marc.info/?l=nginx&m=120127282911304&w=2
JavaScript/DOM/XML 11 Sep 2008 05:50 pm
静态html用js取中文参数,无乱码
<coolcode>
<script type=”text/javascript”>
String.prototype.getQueryString = function(name)
{
var reg = new RegExp(”(^|&|\\?)”+ name +”=([^&]*)(&|$)”), r;
if (r=this.match(reg)) return unescape(r[2]); return null;
};
</script>
<script>
var msg=window.location.href.getQueryString(”msg”);
if (msg)
{
document.write(’<li>· ’+msg+’</li>’);
}
</script>
</coolcode>
在ff下中文会乱码,参数传递过来时需先escape();
<coolcode>
function phpescape($str){
preg_match_all(”/[\x80-\xff].|[\x01-\x7f]+/”,$str,$newstr);
$ar = $newstr[0];
foreach($ar as $k=>$v){
if(ord($ar[$k])>=127){
$tmpString=bin2hex(iconv(”GBK”,”ucs-2″,$v));
if (!eregi(”WIN”,PHP_OS)){
$tmpString = substr($tmpString,2,2).substr($tmpString,0,2);
}
$reString.=”%u”.$tmpString;
} else {
$reString.= rawurlencode($v);
}
}
return $reString;
}
</coolcode>
参考:
PHP实现Javascript的escape(),unescape()的方法
网站建设 11 Sep 2008 11:06 am
Google 企业应用套件
http://www.google.com/a/help/intl/zh-CN/admins/editions_spe.html
专业版为US$50.00美元/用户帐户/年。
免费版支持100个账号的7G邮箱,支持pop、smtp、imap,中文界面。
带Google Talk, Google 日历, Google 文件, 初始页, 移动访问 ,Google Page Creator 等免费服务。
中文界面到了第二步填写信息的时候,总是会提示你选择的国家(中国)”Google 企业应用套件目前不支持该国家/地区的域名。”
这里有个问题: 最重要的是要通过美国的代理服务器访问;
1 申请的域名必须是.com域名的邮箱:如果有.cn com.cn域名需要申请,可以先申请一个.com域名的,然后设置另外的.cn .com.cn域名为相应的.com域名的别名即可;
2 申请的国家填写美国: 注册页面是有IP对应国家的校验的,所以要通过美国的代理服务器才能提交通过;
可以使用putty
登录设置中配置tunnel,目标设置为Dynamic,添加一个端口7070,再按Add,一个动态转发端口就实现了;
然后用相应帐号ssh登录后:除了登录的终端窗口意外,本地的7070连服务器的22端口之间就有了一个SSH加密的转发通道了。
为了方便切换,可以使用FireFox的SwitchProxy tool插件,设置socks代理通过本地的127.0.0.1:7070 进行传输。
3 电话号码填写一个合法的美国电话号码:555 222-2222;
注册后:
1 会有域名拥有者校验:
在网站根域名的目录下,上传一个带有校验码的googlehostedservice.html文件;
2 域名MX记录修改等,基本上按照提示修改即可
ASPMX.L.GOOGLE.COM. 10
ALT1.ASPMX.L.GOOGLE.COM. 20
ALT2.ASPMX.L.GOOGLE.COM. 30
ASPMX2.GOOGLEMAIL.COM. 40
ASPMX3.GOOGLEMAIL.COM. 50
ASPMX4.GOOGLEMAIL.COM. 60
ASPMX5.GOOGLEMAIL.COM. 70
如果域名mx解析不够,可以只用ASPMX.L.GOOGLE.COM.
邮箱服务的入口:https://mail.google.com/a/c1gstudio.com/
初始页的入口:http://partnerpage.google.com/c1gstudio.com
客户端收发邮件
- 登录到您的 Gmail 帐户。
- 点击任一 Gmail 页顶部的设置。
- 点击橙色框邮件设置中的转发和 POP。
- 选择针对所有邮件启用 POP 或者针对从现在起开始接收的邮件启用 POP。
- 使用 POP 访问 Gmail 邮件后,选择您要对邮件采用的处理方式。
- 配置 POP 客户端* 然后点击保存更改。
在客户端设置
POP服务器:pop.gmail.com 995
SMTP:smtp.gmail.com 25
用户名:你的企业邮箱邮件地址(包括@c1gstudio.com)
密码:你自己的企业邮箱密码
需要启动SSL(可参考gmail相关页面)
参考:
免费企业邮箱: Google企业邮箱的申请
其它 & 分析报告 09 Sep 2008 03:49 pm
log中的_vti_bin/owssvr.dll 和/MSOffice/cltreq.asp
404记录
| /_vti_bin/owssvr.dll | - | |
| /MSOffice/cltreq.asp |
此及IE工具栏上的”讨论”按钮产生(需ms office)
Web Server/Apache/Nginx & linux 维护优化 & 技术 08 Sep 2008 04:34 pm
设置apache 日志不记录图片
<FilesMatch “\.(gif|jpg|jpeg|png|css|swf)”>
SetEnv NoLOG 1
</FilesMatch>
CustomLog logs/www.c1gstudio.com-access_log common env=!NoLOG
对于找不到图片的还是会记录在log中的