海运的博客

Linux/Centos服务器禁止udp发包防udp-flood攻击

发布时间:April 23, 2012 // 分类:网络安全 // No Comments

有的网站被恶意放上UDP发包工具攻击别人,导致流量大量流失,一般服务器只有DNS使用udp协议,其它则可禁用UDP数据包外出。
为此写了个脚本只允许目标DNS服务器的UDP数据包外出,其它UDP数据包全部拒绝,本方法仅能做到防止恶意UDP数据包发出,服务器本身做好安全设置防止被恶意放马才是王道。

#/bin/bash
#Createdby https://www.haiyun.me
#DROP UDP Flood
list=`grep nameserver /etc/resolv.conf |awk '{print $NF}'`
for i in $list
do
        iptables -A OUTPUT -p udp -d $i --dport 53 -j ACCEPT
done
iptables -A OUTPUT -p udp -j DROP
service iptables save

飞飞影视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
分类
最新文章
最近回复
  • opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
  • liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
  • 海运: 不好意思,没有。
  • zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档