海运的博客

Kloxo下Apache报错NameVirtualHost has no VirtualHosts解决

发布时间:December 18, 2012 // 分类:控制面板 // No Comments

Kloxo面板重启Apache时提示以下错误:

[Tue Dec 18 22:07:51 2012] [warn] NameVirtualHost 8.8.8.8:80 has no VirtualHosts
[Tue Dec 18 22:07:51 2012] [warn] NameVirtualHost 8.8.8.8:443 has no VirtualHosts

原因是在以下配置文件内重复设置NameVirtualHost,注释一个即可。

/etc/httpd/conf/kloxo/init.conf
/etc/httpd/conf/kloxo/virtualhost.conf

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

Awstats分析Nginx和IIS日志

发布时间:June 23, 2012 // 分类:日记分析 // No Comments

Awstat默认支持Apache日记格式,IISNginx需修改日志记录格式 。
IIS自定义日志格式为:

#https://www.haiyun.me
date
time
c-ip
cs-username
cs-method
cs-uri-stem
cs-uri-query
sc-status
sc-bytes
cs-version
cs(User-Agent)
cs(Referer)

然后配置文件日记类型更改为2,1为Apache

LogFormat=1

2.Nginx调整日志为Apache格式:

#https://www.haiyun.me
log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • 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 论坛没找到好方法,博...