举例有html内容如下
abc | abc | abc |
需将
也可以这样 查找内容:<td(.)>(.)
关注互联网、网页设计、Web开发、服务器运维优化、项目管理、网站运营、网站安全…
举例有html内容如下
abc | abc | abc |
需将
也可以这样 查找内容:<td(.)>(.)
rev="post-256" No comments
– 2008/09/16
默认配置当你访问http://abc.example.com/dir 时不会加”/”
常见做法
if (-d $request_filename){ rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent; }更佳的替代方法
optimize_server_names off;#优化服务器名称:关 server_name_in_redirect off;#服务器名称重定向:关
http://wiki.codemongers.com/NginxHttpCoreModule#optimize_server_names
rev="post-254" No comments
– 2008/09/16
apache限制ip方法
documentroot “/opt/htdocs/www/” servername admin.c1gstudio.com 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使用ngx_http_access_module限制ip访问
官方示例 http://wiki.codemongers.com/NginxHttpAccessModule#allow
location / { deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; deny all; }改成自已的
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; }结果:测试下来非定义的ip还是可以访问。
再修改下正则
location ^~ / { allow 127.0.0.1; allow 222.222.222.222;#服务器ip allow 111.111.111.111;#自已电脑的ip deny all; }结果:非定义的是ip不可以访问了,但php变明文显示,perl是404。
你可以看看 nginx 的文档里面关于 location 的说明。它的匹配方式是 正则表达式 优先级比较高。 就是说,你的 PHP 解析用的是 正则表达式进行匹配,而你要限制的目录不是用正则表达式,所以,就算是要限制的目录,因为PHP还是能被匹配到,所以,还是解析PHP了。所以,如果想解决的话,可能需要把目录也写成正则匹配,而且要放在PHP的前面,否则就会先匹配PHP |
satisfy_any on;
http://www.freebsdchina.org/forum/viewtopic.php?t=42141
使用多级目录将保护目录放在根中
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; } }结果:有效
整个域名需禁止访问可以写在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; } } }Posted in Apache, Nginx, 安全, 技术.
rev="post-248" No comments
– 2008/09/16
String.prototype.getQueryString = function(name) { var reg = new RegExp(“(^|&|\?)”+ name +”=([^&]*)(&|$)”), r; if (r=this.match(reg)) return unescape(r[2]); return null; }; var msg=window.location.href.getQueryString(“msg”); if (msg) { document.write(‘
在ff下中文会乱码,参数传递过来时需先escape();
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; }
参考:
Posted in JavaScript/DOM/XML.
rev="post-246" 1 comment
– 2008/09/11
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
客户端收发邮件
在客户端设置 POP服务器:pop.gmail.com 995 SMTP:smtp.gmail.com 25
用户名:你的企业邮箱邮件地址(包括@c1gstudio.com) 密码:你自己的企业邮箱密码
需要启动SSL(可参考gmail相关页面)
参考: 免费企业邮箱: Google企业邮箱的申请
Posted in 网站建设.
rev="post-244" No comments
– 2008/09/11
404记录
/_vti_bin/owssvr.dll | – | |
/MSOffice/cltreq.asp |
此及IE工具栏上的”讨论”按钮产生(需ms office)
rev="post-242" No comments
– 2008/09/09
SetEnv NoLOG 1
CustomLog logs/www.c1gstudio.com-access_log common env=!NoLOG
对于找不到图片的还是会记录在log中的
Posted in Apache, linux 维护优化, 技术.
rev="post-240" No comments
– 2008/09/08
http://sourceforge.net/projects/awstats/ #wget http://nchc.dl.sourceforge.net/sourceforge/awstats/awstats-6.8.tar.gz 车东的内主要搜索引擎和蜘蛛定义 #wget http://www.chedong.com/tech/lib.tgz 下载GeoIP的应用库:C http://www.maxmind.com/download/geoip/api/c/ #wget http://www.maxmind.com/download/geoip/api/c/GeoIP.tar.gz 下载GeoIP/GeoIPCityLite包:解包并部署到awstats目录下 #wget http://www.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz #wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
# tar zxvf GeoIP.tar.gz #cd GeoIP-1.4.4 #./configure #make && make install #cd ..
#tar zxvf awstats-6.8.tar.gz #mv awstats-6.8 /opt/awstats
#gunzip lib.tgz #tar xvf lib.tar 覆盖原文件 #\cp -a lib/* /opt/awstats/wwwroot/cgi-bin/lib/
#gunzip GeoIP.dat.gz #gunzip GeoLiteCity.dat.gz #cp GeoIP.dat /opt/awstats/wwwroot/cgi-bin/plugins/ #cp GeoLiteCity.dat /opt/awstats/wwwroot/cgi-bin/plugins/
设置权限 #chown -R www:website /opt/awstats #chmod 0755 //opt/awstats/wwwroot/cgi-bin/plugins/Geo*
perl -MCPAN -e ‘install “Geo::IP”‘ 或者使用纯Perl包 perl -MCPAN -e ‘install “Geo::IP::PurePerl”‘ #perl -MCPAN -e ‘install “Geo::IP”‘ 一路回车到底
如果失败可以手动安装Geo::IP,并指定库的路径 #wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz #tar zxvf Geo-IP-1.38.tar.gz #cd Geo-IP-1.38 #perl Makefile.PL LIBS=’-L/usr/local/lib’ INC=’-I/usr/local/include’ #make && make install
配置awstats #cd /opt/awstats/tools/ #perl awstats_configure.pl —–> Running OS detected: Linux, BSD or Unix Warning: AWStats standard directory on Linux OS is ‘/usr/local/awstats’. If you want to use standard directory, you should first move all content of AWStats distribution from current directory: /opt/awstats to standard directory: /usr/local/awstats And then, run configure.pl from this location. Do you want to continue setup from this NON standard directory [yN] ?
y
—–> Check for web server install Enter full config file path of your Web server. Example: /etc/httpd/httpd.conf Example: /usr/local/apache2/conf/httpd.conf Example: c:\Program files\apache group\apache\conf\httpd.conf Config file path (‘none’ to skip web server setup):
指定httpd.conf的路径,我用nginx输入none
—–> Update model config file ‘/opt/awstats/wwwroot/cgi-bin/awstats.model.conf’ File awstats.model.conf updated. —–> Need to create a new config file ? Do you want me to build a new AWStats config/profile file (required if first install) [y/N] ?
我使用手工写的conf所以输入n
—–> Add update process inside a scheduler Sorry, configure.pl does not support automatic add to cron yet. You can do it manually by adding the following command to your cron: /opt/awstats/wwwroot/cgi-bin/awstats.pl -update -config=myvirtualserver Or if you have several config files and prefer having only one command: /opt/awstats/tools/awstats_updateall.pl now Press ENTER to continue…
然后回车
将缺省awstats.model.conf 命名成common.conf #cd ../wwwroot/cgi-bin/ #mv awstats.model.conf common.conf 修改其中的一些配置选项: #vi common.conf 按”/”输入decodeutfkeys 去掉此行前的”#” LoadPlugin=”decodeutfkeys”
查找geoip GEOIP_STANDARD和geoip_city_maxmind ,去掉注释并改成你的路径 LoadPlugin=”geoip GEOIP_STANDARD /opt/awstats/wwwroot/cgi-bin/plugins/GeoIP.dat” LoadPlugin=”geoip_city_maxmind GEOIP_STANDARD /opt/awstats/wwwroot/cgi-bin/plugins/GeoLiteCity.dat
按照一下样例设置配置文件: #vi /etc/awstats/awstats.www.c1gstudio.com.conf Include “/opt/awstats/wwwroot/cgi-bin/common.conf” LogFile=”gzip -d </opt/nginx/logs/www.c1gstudio.com.%YYYY-24%MM-24%DD-24.log.gz |" SiteDomain="www.c1gstudio.com" HostAliases="c1gstudio.com127.0.0.1 localhost" DirData="/var/lib/awstats"
创建数据目录 #mkdir /var/lib/awstats
成生报告 #perl /opt/awstats/wwwroot/cgi-bin/awstats.pl -config=www.c1gstudio.com -update
查看报告 http://www.c1gstudio.com/cgi-bin/awpstats.pl?config=www.c1gstudio.com
定时更新 10 5 * (cd /opt/awstats/wwwroot/cgi-bin/;./awstats.pl -update -config=www.c1gstudio.com)
参考资料 http://www.chedong.com/tech/awstats.html http://blog.s135.com/read.php/199.htm 测试环境 as4 nginx0.6.32
Posted in 技术.
rev="post-231" No comments
– 2008/09/04
pear remote-list HTTP error, got response: HTTP/1.1 404 Not Found Didn’t receive 200 OK from remote server. (HTTP/1.1 404 Not Found)
pear upgrade –force http://pear.php.net/get/Archive_Tar http://pear.php.net/get/XML_Parser http://pear.php.net/get/Console_Getopt-1.2.2 pear upgrade –force http://pear.php.net/get/PEAR-1.3.3 (IF your existing version is older than 1.3.3) pear upgrade –force http://pear.php.net/get/PEAR-1.4.3.tar pear upgrade PEAR
pear remote-list
Posted in 技术.
rev="post-192" No comments
– 2008/09/04
http://wiki.codemongers.com/NginxHttpCoreModule#error_page
error_page 404 = /404.php;我没仔细看,漏掉了中间的 “= , 以为nginx 404 不能再用php 控制header。 在网上转的半天也学到一些东东
fastcgi_hide_header X-Powered-By; # 在header里隐藏php的版本 #fastcgi_pass_header Location;#在header里显示location #fastcgi_pass_header Status; fastcgi_pass_header Authorization;自定义http 状态码 https://calomel.org/nginx.html
使用recursive_error_pages on;递归404来找归档文件或使用memcache http://marc.info/?l=nginx&m=120127277410400&w=2 http://blog.arh.cc/index.php?/archives/11-Simple-and-clean-nginx.conf.html
rev="post-211" No comments
– 2008/08/28
近期评论