Apache2.0.54 detailed configuration for preventing unauthorized connections

Source: Internet
Author: User

Source: Perls Blog


To enable apache anti-theft connection, you must first enable apache to support. htaccess client setting files and add the mod_rewrite module. The following is my compilation and installation process.
1. install apache and add the mod_rewrite module.
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: Compile the od_rewrite Module
Make
Make install
View the modules compiled by apache
[Root @ TFP httpd-2.0.54] #/usr/local/httpd/bin/apachectl-l
Compiled in modules:
Core. c
Mod_access.c // supports. htaccess files
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 has been compiled.
Mod_so.c
[Root @ TFP httpd-2.0.54] #
2. Set the apache configuration file httpd. conf

Options FollowSymLinks
AllowOverride All: Change None to All

 

AllowOverride All: Change None to All
Remove the default APACHE name # Before ServerName # Set it to 127.0.0.1
ServerName 127.0.0.1
Set VM

NameVirtualHost 220.202.19.82

DocumentRoot/home/down
ServerName down.sy165.cn


Restart Apache2 server
Next, create a. htaccess file. The content of the. htaccess file is
RewriteEngine on
RewriteCond % {HTTP_REFERER }! ^ Http://www.sy165.cn/.#$ [NC]
RewriteCond % {HTTP_REFERER }! ^ Http://www.sy165.cn $ [NC]
RewriteRule. *. (jpg | jpeg | gif | png | bmp | rar | zip | exe) $ http://www.sy165.cn/err.htm [R, NC]

Put this file in the/home/down directory.
RewriteCond % {HTTP_REFERER }! ^ Http://www.sy165.cn/.#$ [NC]
You can only download files under down.sy165.cn.
RewriteCond % {HTTP_REFERER }! ^ Http://www.sy165.cn $ [NC]
Down.sy165.cn files can only be downloaded through www.sy165.cn
RewriteRule. *. (jpg | jpeg | gif | png | bmp | rar | zip | exe) $ http://www.sy165.cn/err.htm [R, NC]
Jpg | jpeg | gif | png | bmp | rar | zip | exe is the content to protect, if the Island connection will jump to the http://www.sy165.cn/err.htm

Test address can be downloaded through http://www.sy165.cn CS1.6 standard version 3147 download
Cannot be downloaded directly through URL: http://down.sy165.cn/game/CS_16_3174.exe

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.