Apache speed limit module mod_b1_dll and anti-leech settings

Source: Internet
Author: User

Recently, there are always problems with IIS, so I can't stand it anymore. I changed the environment of the fire main site and the download topic to Apache. After the change, many problems will arise, such as the speed limit in IIS and anti-Leech, which should be reset and searched for details.

There is only one way to achieve speed limit first, as shown below:

Bw_mod can limit the bandwidth based on the source IP address.

Download compiled for Windows: http://www.veryhuo.com/down/html/29247.html

1. Install the mod_b1_dll Module
Put the downloaded mod_b1_dll in the directory apache2.x \ modules.

2. modify the configuration file httpd. conf of Apache.
Add the following to the apache2.x \ conf \ httpd. conf file:
# Speed limiting Module
Loadmodule bw_module modules/mod_bw.dll

3. Activate the bw_module module in the VM.
To restrict all hosts, add the following in the configuration file: apache2.x \ conf \ httpd. conf:
# Add speed control Mo
Bandwidthmodule on
Forcebandwidthmodule on
Bandwidth all 409600

There are two methods to implement anti-leech protection:

1. Implement with rewrite

Make sure thatRewrite ModuleAvailable: Control ApacheHttpd. confFile, open httpd. conf, and make sure there is such a line of Configuration:

LoadModule rewrite_module modules/mod_rewrite.so

Add the following code to the configuration of your website:

Servername liehuo.net # anti-leech configuration rewriteengine onrewritecond % {http_referer }! ^Http://liehuo.net/. * $ [Nc] rewritecond % {http_referer }! ^Http://liehuo.net$ [Nc] rewritecond % {http_referer }! ^Http://www.veryhuo.com/. * $ [Nc] rewritecond % {http_referer }! ^Http://www.veryhuo.com$ [Nc] rewriterule .*\.(GIF | JPG | SWF) $Http://www.veryhuo.com/about/nolink.png[R, NC]

  Anti-leech configuration instructions:

  1. RED: indicates your trusted site. For my site, set to http://www.veryhuo.com and http://liehuo.net
  2. Green: the extension of the file to be protected (separated by | ). Files with these extensions must be referenced by the URL marked in red before they can be accessed.
  3. Blue part: Redirection page after leeching. Used to output warning information. This picture should be as small as possible. For example, my warning image is http://www.veryhuo.com/about/nolink.png. For the sake of simple processing, my green font section, the image to be protected is extended and there is no. PNG image, and the warning image is. PNG. (There are no. PNG images on my site)

Restart the Apache server.

Some users useVirtual HostWithout Server Control, you cannot modify the httpd. conf file or restart the server. Confirm your VM support. Htaccess, Write the above configuration to The. htaccess file, and put it in the root directory or the directory where the image is located:

Content of the. htaccess file: # rewriteengine onrewritecond % {http_referer} in anti-leech configuration }! ^Http://liehuo.net/. * $ [Nc] rewritecond % {http_referer }! ^Http://liehuo.net$ [Nc] rewritecond % {http_referer }! ^Http://www.veryhuo.com/. * $ [Nc] rewritecond % {http_referer }! ^Http://www.veryhuo.com$ [Nc] rewriterule .*\.(GIF | JPG | SWF) $Http://www.veryhuo.com/images/nolink.png[R, NC]

Note:

  1. The configuration in the httpd. conf file is read once at Apache startup, which is highly efficient.
  2. The configuration in the. htaccess file requires reading and analyzing each access, which is very inefficient.

2. Modify the httpd. conf file

Another method is to useSetenvifnocaseAndAccess. The specific code is as follows:

SetEnvIfNoCase Referer "^http://liehuo.net" local_ref=1SetEnvIfNoCase Referer "^http://www.veryhuo.com" local_ref=1Order Allow,DenyAllow from env=local_ref

Put the above Code into the httpd. conf or. htaccess file mentioned above.

Here is the reference of Wood:

The location is usually in/usr/local/Apache/CONF/httpd. conf
Or Apache 2.2/usr/local/apache2/CONF/extra/httpd-vhost.conf
Add

  1. Setenvifnocase Referer "^ http://www.ccvita.com" local_ref = 1
  2. Setenvifnocase Referer "^ http://ccvita.com" local_ref = 1
  3. <Filesmatch "\. (txt | Doc | MP3 | zip | RAR | JPG | GIF)">
  4. Order allow, deny
  5. Allow from Env = local_ref
  6. </Filesmatch>

Here, your url is in bold. If there are multiple URLs, add multiple lines.
The italics are the suffix of the files that you need to anti-leech protection, separated by |

 

Another method is to use regular expressions, which are common in Apache of different versions.
Statement:

  1. Setenvifnocase Referer "^ http: //. * \. yourdomin \. com" local_ref = 1
  2. Setenvifnocase Referer ". * \. yourdomin \. com" local_ref = 1
  3. <Filesmatch "\. (txt | Doc | MP3 | zip | RAR | JPG | GIF)">
  4. Order allow, deny
  5. Allow from Env = local_ref
  6. </Filesmatch>

The bold part has a difference. It is written in regular expressions and the \ symbol represents the escape, because the. itself has its own role in regular expressions.

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.