海运的博客

飞飞影视Nginx伪静态规则

发布时间:April 23, 2012 // 分类:伪静态 // No Comments

2.0版本:

location / {
rewrite ^/vod-(.*)\.html$ /index.php?s=/Home-vod-$1 last;
rewrite ^/news-(.*)$ /index.php?s=/Home-news-$1 last;
rewrite ^special-(.*)$ /index.php?s=/Home-special-$1 last;
rewrite ^/tag-(.*)$ /index.php?s=/Home-tag-$1 last;
rewrite ^/gb-(.*)$ /index.php?s=/Home-gb-$1 last;
rewrite ^/cm-(.*)$ /index.php?s=/Home-cm-$1 last;
rewrite ^/map-(.*)$ /index.php?s=/Home-map-$1 last;
rewrite ^/my-(.*)$ /index.php?s=/Home-my-$1 last; 
rewrite ^/Tpl/(.*)/Home/(.*).html$ /index.php last;
}

1.9版本:

rewrite ^/vod-(.*)\.html$ /index.php?s=/Home-vod-$1;
rewrite ^/news-(.*)$ /index.php?s=/Home-news-$1;
rewrite ^/ajax-(.*)$ /index.php?s=/Home-ajax-$1;
rewrite ^/tag-(.*)$ /index.php?s=/Home-tag-$1;
rewrite ^/gb-(.*)$ /index.php?s=/Home-gb-$1;
rewrite ^/cm-(.*)$ /index.php?s=/Home-cm-$1;

Cacti添加监控服务器网卡流量及资源占用

发布时间:April 23, 2012 // 分类:Cacti // 2 Comments

之前有介绍Cacti中文版安装与配置,这篇文章记录如何添加监控服务器及监控内容。
被监控服务器安装配置SNMP服务:

yum -y install net-snmp #snmp服务
yum -y install net-snmp-utils #使用snmpwalk需要

添加或修改SNMP配置:

vim /etc/snmp/snmpd.conf 
com2sec notConfigUser  default       public #public为验证字符,可自定义修改,后cacti配置会用到
access  notConfigGroup ""      any       noauth    exact  systemview none none #systemview修改为all
view all    included  .1           80 #添加此行

然后登录Cacti界面添加被监控服务器,点击设备——右上角添加,输入被监控服务器IP或域名,设置模板,SNMP验证字符、端口。
cacti新建监控服务器.png
添加成功会出现此画面:
cacti添加服务器成功snmp信息.png
然后点击为此设备生成图像,选择相应的监控内容。
cacti添加监控内容.png
点击创建,如果成功会提示:
cacti生成图像成功.png
到此就算添加监控服务器完成了,过几分钟在查看图像处就可看到监控生成的图像了。
cacti流量监控图表.png

Nginx安装字符替换模块substitutions_filter

发布时间:April 22, 2012 // 分类:Nginx // No Comments

substitutions_filter是Nginx的一个扩展模块,用来搜索并替换应答内容中的文本,配合nginx的反向代理有妙用哦。
添加此模块需重新编译Nginx,LNMP编译升级请参考:LNMP平滑升级
首先获取substitutions_filter:

yum -y install subversion
svn checkout http://substitutions4nginx.googlecode.com/svn/trunk/ substitutions4nginx-read-only

编译Nginx时添加:

./configure --add-module=/path/substitutions4nginx-read-only

使用语法:

subs_filter 源字符 目标字符 [gior] 
#g:替换全部
#o:替换首个
#i:不区分大小写
#r:使用正则替换

使用范例:

location / {
    subs_filter_types text/html text/css text/xml; #替换的文件类型
    subs_filter st(\d*).onovps $1.www.haiyun.me ir; #
    subs_filter www.haiyun.me www.haiyun.me;
}

注意:开启GZIP后不能替换,需关闭:

proxy_set_header Accept-Encoding "";

Nginx配置透明代理缓存服务器

发布时间:April 22, 2012 // 分类:Nginx // 5 Comments

之前有介绍过Squid构建透明代理缓存服务器Nginx就比较全能了,做为透明代理也不错。
修改Nginx配置文件,在http段添加:

proxy_cache_path /path/proxy_cache levels=1:2 keys_zone=cache_one:30m inactive=10d max_size=10g;
#定义缓存名称cache_one,2级目录,内存缓存30M,硬盘10G,10未访问内容删除
proxy_temp_path /path/proxy_tmp;

server段配置:

server {
    listen 3128;
    resolver 8.8.8.8;
    proxy_cache cache_one;
    proxy_max_temp_file_size 10m;
 
    location / {
        proxy_pass http://$host$request_uri;
        proxy_connect_timeout   60;
        proxy_send_timeout     60;
        proxy_read_timeout     60;
    }
        
         location ~ .*\.(php|jsp|cgi|asp)?$ {
                 proxy_pass http://$host$request_uri;
               }
}

Iptables配置:

iptables -t nat -A PREROUTING -i br-lan -p tcp  --dport 80 -j REDIRECT --to-ports 3128

固定NFS启动端口便于iptables设置

发布时间:April 22, 2012 // 分类:Linux服务 // No Comments

NFS启动时会随机启动多个端口并向RPC注册,这样如果使用iptables对NFS端口进行限制就会有点麻烦,可以更改配置文件固定NFS服务相关端口。
先上张图看看NFS启动后的端口:
nfs-port.png
分配端口,编辑配置文件:

vi /etc/sysconfig/nfs 

添加:

#https://www.haiyun.me
RQUOTAD_PORT=30001
LOCKD_TCPPORT=30002
LOCKD_UDPPORT=30002
MOUNTD_PORT=30003
STATD_PORT=30004

重启portmap和nfs:

/etc/init.d/portmap restart
/etc/init.d/nfs restart

现在看看启动的端口:

rpcinfo -p localhost

2012-04-22_185346.png
iptables设置:

iptables -A INPUT -s 192.168.1.1 -p tcp --dport 111 -j ACCEPT
iptables -A INPUT -s 192.168.1.1 -p udp --dport 111 -j ACCEPT
iptables -A INPUT -s 192.168.1.1 -p tcp --dport 2049 -j ACCEPT
iptables -A INPUT -s 192.168.1.1 -p udp --dport 2049 -j ACCEPT
iptables -A INPUT -s 192.168.1.1 -p tcp --dport 30001:30004 -j ACCEPT
iptables -A INPUT -s 192.168.1.1 -p udp --dport 30001:30004 -j ACCEPT
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
归档