Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6894846
  • 博文数量: 637
  • 博客积分: 10265
  • 博客等级: 上将
  • 技术积分: 6165
  • 用 户 组: 普通用户
  • 注册时间: 2004-12-12 22:00
文章分类

全部博文(637)

文章存档

2011年(1)

2010年(1)

2009年(3)

2008年(12)

2007年(44)

2006年(156)

2005年(419)

2004年(1)

分类: 系统运维

2006-01-02 21:52:57



阅读:20173 时间:2005-8-11 15:08:05 来源:
要让apache防盗连接,首先要让apache支持.htaccess客户设置文件,还要增加mod_rewrite模块。以下是我的编译安装过程。
1. 安装apache增加mod_rewrite模块
tar xfzv httpd-2.0.54.tar.gz
cd httpd-2.0.54
./configure --prefix=/usr/local/httpd --enable-module=most --enable-shared=max --enable-rewrite
--enable-rewrite将od_rewrite模块编译进来
make
make install
查看apache编译进来的模块
[root@TFP httpd-2.0.54]# /usr/local/httpd/bin/apachectl -l
Compiled in modules:
 core.c
 mod_access.c   //支持.htaccess文件
 mod_auth.c
 mod_include.c
 mod_log_config.c
 mod_env.c
 mod_setenvif.c
 prefork.c
 http_core.c
 mod_mime.c
 mod_status.c
 mod_autoindex.c
 mod_asis.c
 mod_cgi.c
 mod_negotiation.c
 mod_dir.c
 mod_imap.c
 mod_actions.c
 mod_userdir.c
 mod_alias.c
 mod_rewrite.c   //已经将od_rewrite编译进来了
 mod_so.c
[root@TFP httpd-2.0.54]#
2.设置apache配置文件httpd.conf

  Options FollowSymLinks
  AllowOverride All  将None修改为All



AllowOverride All    将None修改为All
修改默认APACHE名去掉#ServerName前的#设置为127.0.0.1
ServerName 127.0.0.1
设置虚拟主机

NameVirtualHost 220.202.19.82

  DocumentRoot /home/down
  ServerName down.sy165.cn


重启Apache2服务器
接下就是做一个 .htaccess 文件了,其 .htaccess 文件内容为
RewriteEngine on
RewriteCond % !^*   [NC]
RewriteCond % !^   [NC]
RewriteRule .*.(jpg|jpeg|gif|png|bmp|rar|zip|exe) /err.htm [R,NC]

将这个文件放到/home/down目录下
RewriteCond % !^*   [NC]
只允许通过*才能下载down.sy165.cn下的文件。
RewriteCond % !^   [NC]
只允许通过才能下载down.sy165.cn下的文件
RewriteRule .*.(jpg|jpeg|gif|png|bmp|rar|zip|exe) /err.htm [R,NC]
jpg|jpeg|gif|png|bmp|rar|zip|exe是要保护的内容,如果岛连接将跳转到/err.htm

测试地址可以通过下载CS1.6 标准版3147版下载
不能直接通过URL: 下载
阅读(2393) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~