海运的博客

Apache/Httpd防DDOS/CC模块mod_evasive安装

发布时间:October 23, 2012 // 分类:Apache // No Comments

Apache模块mod_evasive利用Hash表储存相应的HTTP请求,利用设定规则判断是否拒绝对方的请求。
安装:

#https://www.haiyun.me
wget http://www.zdziarski.com/blog/wp-content/uploads/2010/02/mod_evasive_1.10.1.tar.gz
tar zxvf mod_evasive_1.10.1.tar.gz 
cd mod_evasive/
apxs -i -a -c mod_evasive20.c
#编译、安装、并加载模块

配置mod_evasive:

<IfModule mod_evasive20.c>
    DOSHashTableSize    3097 #表大小
    DOSPageCount        2 #限制单位时间内同一IP请求同一网页次数
    DOSSiteCount        10 #限制单位时间内同一IP请求网站次数
    DOSPageInterval     1 #网页存取间隔
    DOSSiteInterval     1 #网站存取间隔
    DOSBlockingPeriod   10 #限制访问时间
    DOSEmailNotify     #疑似攻击时邮件通知
    DOSSystemCommand "su - onovps -c iptables -I INPUT -s %s --dport 80 -j DROP" 
    #疑似攻击时用防火墙限制IP访问80端口
    DOSLogDir  "/var/log/    #日志目录
    DOSWhiteList 127.0.0.1 #添加白名单
</IfModule>

重启Apache生效:

/etc/init.d/httpd restart

同时作者还提供了一个测试程序用以测试mod_evasive是否生效:

perl test.pl 
HTTP/1.1 200 OK
HTTP/1.1 403 Forbidden

Apache/Httpd安装mod_pagespeed加速模块

发布时间:October 15, 2012 // 分类:Apache // 1 Comment

mod_pagespeed是谷歌发布的加速httpd的优化模块,通过自动优化代码、压缩传输内容、自动缓存加速http,支持Centos/Debian系统。
Centos/Fedora下安装:

#https://www.haiyun.me
#32位
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.rpm
#64位
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm
yum install at
rpm -U mod-pagespeed-*.rpm

Debina/Ubuntu下安装:

#32位
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i386.deb
#64位
wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.deb
dpkg -i mod-pagespeed-*.deb

重启httpd:

services httpd restart

查看pagespeed是否加载:

httpd -M|grep pagespeed

Apache添加密码认证

发布时间:July 10, 2012 // 分类:Apache // No Comments

生成用户、密码文件:

htpasswd -c /etc/httpd/passwd user

1.直接编辑Apache配置添加认证:

#https://www.haiyun.me
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "Httpd Access"
AuthType Basic
AuthUserFile /etc/httpd/passwd
Require valid-user
</Directory>

2.以.htaccess认证,首先授权相应网站建.htaccess验证权限:

Options Indexes FollowSymLinks
AllowOverride AuthConfig 
Order allow,deny
Allow from all

在验证目录新建.htaccess文件:

AuthName "Httpd Access"
AuthType Basic
AuthUserFile /etc/httpd/passwd
Require valid-user

Apache/PHP/Mysql/Nginx编译参数查看

发布时间:June 20, 2012 // 分类:Apache,Nginx,PHP,数据库 // No Comments

查看Nginx编译参数:

/usr/local/nginx/sbin/nginx -V

查看Apache编译参数:

cat /usr/local/apache/build/config.nice

查看PHP编译参数:

/usr/local/php/bin/php -i |grep configure

查看Mysql编译参数:

cat /usr/local/mysql/bin/mysqlbug|grep configure

Apache动态编译添加模块

发布时间:May 22, 2012 // 分类:Apache // No Comments

Apache基于模块化设计,编译完成后还可动态编译添加其它模块,此功能Apache编译时需添加--enable-so参数,1.x版本--enable-module=so。
查看已加载的模块:

#https://www.haiyun.me
/usr/local/httpd/bin/httpd -M

以编译添加expires模块为例:

cd /src/httpd/modules/metadata/ #进入源码模块目录
/usr/local/httpd/bin/apxs -c -i -a mod_expires.c #编译、安装、启用expires模块
/etc/init.d/httpd restart #重新启动httpd加载
分类
最新文章
最近回复
  • 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 论坛没找到好方法,博...
  • jiangker: good, very helpful to me
  • fengfeng: N1 armbian 能有编译下内核吗。。我要开启can 不懂怎么操作