Home mail me! Syndicate this site using RSS

Archive for October, 2006


使用DenyHosts阻止SSH暴力破解

公司服务器每天都会有上千的SSH失败尝试记录,一直不停的扫描,这些人真够无 聊的,没事吃饱了撑着,尽找些软件在那里穷举扫描(幸好服务器密码设置的够长够复杂)。

要一条一条将这些IP阻止显然治标不治本,于是找了个DenyHosts软件来代替的偶的手工活,吼吼:)

DenyHosts是Python语言写的一个程序,它会分析SSHD的日志文件,当发现重复的攻击时就会记录IP到/etc/hosts.deny文件,从而达到自动屏蔽IP的功能。

DenyHosts官方网站为:http://denyhosts.sourceforge.net

以下是安装记录(以CentOS 4.4, DenyHosts 2.5 为例)
Read more…

CentOS下安装MRTG

1、安装SNMPD服务
# yum install net-snmp-utils
# vi /etc/snmp/snmpd.conf
把以下的内容注释掉:

# First, map the community name "public" into a "security name"

#       sec.name  source          community
##com2sec notConfigUser  default       public

####
# Second, map the security name into a group name:

#       groupName      securityModel securityName
##group   notConfigGroup v1           notConfigUser
##group   notConfigGroup v2c           notConfigUser

####
# Third, create a view for us to let the group have rights to:

# Make at least  snmpwalk -v 1 localhost -c public system fast again.
#       name           incl/excl     subtree         mask(optional)
##view    systemview    included   .1.3.6.1.2.1.1
##view    systemview    included   .1.3.6.1.2.1.25.1.1

####
# Finally, grant the group read-only access to the systemview view.

#       group          context sec.model sec.level prefix read   write  notif
##access  notConfigGroup ""      any       noauth    exact  systemview none none

Read more…

加速APACHE访问速度及节省网络带宽

APACHE提供了一个mod_deflate模块,用于内容输出压缩过滤功能,可以有效的提高网站的访问速度及节省大量的带宽,所付出的成本是会对CPU增加微量的负担,因 此对于那些访问量非常大而带宽又不足的网站是个非常不错的选择。

本文依然以CentOS 4.4下的APACHE为例,默认安装下已经安装了mod_deflate模块,所要做的就是少量的配置而已。

# vi /etc/httpd/conf/httpd.conf

Read more…

高负载WEB动态页面与静态页面的分离

试了一段时间的Lighttpd,表现的确不错,原先用APACHE只能跑到6K/S,改用Lighttpd后性能提升了将近一倍,只是跑PHP似乎很不稳定,数据库处理时间长一点就会到导致Lighttpd出现500的错误,也就是说要想使Lighttpd发挥更好的性能,除了优化程序还是优化程序,尽可能的加快PHP的执行速度,另外加上eAccelerator性能会有更大的提高。

说了这么多优点,再来说说公司最近所尝试的一些经验,PHP程序已被优化的不能再优化了,但是有时候操作一下数据库(比如执行mysqldump)就会出现500错误,并发量非常大的时候很容易出现,在这点上Lighttpd的表现就没有Apache稳定了,所以想了一个折中的办法,让Apache来处理PHP程序,其他的静态页面(包括图片、软件等等)全都交给Lighttpd来处理。而实现方法就是通过mod_proxy来实现,Apache做前端处理或Lighttpd做前端处理都行,反正这2种都有个mod_proxy模块,基本上一样。
Read more…