Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Realization of hotlink protection under apache

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is a hotlink?

Hotlink refers to displaying some content on your own page that is not on your server. The usual practice is to obtain the resource address on someone else's server by technical means.

Bypass other people's resource display pages and provide this content directly to the end user on your own page.

It is more common that some small stations embezzle the resources of large stations (pictures, music, videos).

For these small stations, the method of stealing links can reduce the burden on their own servers, because the real space and traffic come from other people's servers.

The impact on large stations does increase the pressure on the server, users, traffic is not their own.

Two servers are used to simulate this situation

172.16.16.6 www.wawa.com is a normal website

172.16.16.6 www.wawawa.com is a website that jumps after the hotlink is stopped.

172.16.16.16 www.aaa.com is a pirated website

This experiment requires Apache-based virtual hosts and DNS, which is not covered here.

Let's take a look at the effect of not doing hotlink protection.

First of all, configure 172.16.16.6 www.wawa.com normal host picture website and prevent jump site

Similarly, first modify the main configuration file vim / etc/httpd/conf/httpd.conf to add virtual hosts and listen for port 80

Then there is the configuration of the hotlink website 172.16.16.16 www.aaa.com

Once the server is configured, verify the effectiveness of the website.

Normal website

In order to distinguish a bootleg website from a normal website, the text of the website is slightly changed as a distinction.

Block the website

You can see that in addition to the different words I modified, pictures and other things can be directly displayed on the hotlink website without configuration, which must be prevented.

Let's configure hotlink protection.

If you use yum to install it, you must have this module. If you don't worry, you can check it.

[root@localhost 20] # cd / etc/httpd/

[root@localhost httpd] # apachectl-D DUMP_MODULES | grep expires

Modify the virtual host file vim / etc/httpd/conf/httpd.conf and add the following scarlet letter before the normal service

DocumentRoot / opt/www/10

ServerName www.wawa.com

AllowOverride None

Require all granted

RewriteEngine On

RewriteCond% {HTTP_REFERER}! ^ http://172.16.16.6/*

RewriteCond% {HTTP_REFERER}! ^ http://wawa.com/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ http://wawa.com$ [NC]

RewriteCond% {HTTP_REFERER}! ^ http://www.wawa.com/.*$ [NC]

RewriteCond% {HTTP_REFERER}! ^ http://www.wawa.com$ [NC]

RewriteRule. *\. (gif | jpg | swf | png) $http://www.wawawa.com/error.jpg [RMagneNC]

Let's visit the hotlink website to see the results.

At this point, hotlink protection is considered a success.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report