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

Nginx Optimization-hotlink Protection

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

Share

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

Hotlink protection demonstration

1. Install and configure DNS domain name resolution service

[root@localhost ~] # yum install bind-y [root@localhost ~] # vim / etc/named.conf options {listen-on port 53 {any;};. Allow-query {any;}; [root@localhost ~] # vim / etc/named.rfc1912.zoneszone "accp.com" IN {type master; file "accp.com.zone"; allow-update {none;};} [root@localhost ~] # cd / var/named/ [root@localhost named] # cp-p named.localhost accp.com.zone# copy template file [root@localhost named] # vim accp.com.zone $TTL 1D @ IN SOA @ rname.invalid. (0; serial 1D; refresh 1H; retry 1W; expire 3H) Minimum NS @ A 127.0.0.1www IN A 192.168.235.158#IP address points to the local address [root@localhost named] # systemctl start named [root@localhost named] # systemctl stop firewalld.service [root@localhost named] # setenforce 0

2. Open a Win7 virtual machine and build a hotlink website. Create a web page content and change the suffix to index.html

Cloud computing this is test web

3. Set up a website

4. Modify the preferred DNS server address

5. Visit the original website and the pirated website respectively

6. Modify Nginx.conf file

[root@localhost named] # vim / usr/local/nginx/conf/nginx.conflocation ~ *\. (jpg | gif | swf) ${# supports format valid_referers none blocked * .accp.com accp.com # allow access to if with accp.com suffix ($invalid_referer) {# to determine whether rewrite ^ / http://www.accp.com/error.png; has been hacked # Redirect the wrong picture if the stolen link is determined}} [root@localhost named] # cp / abc/error.png / usr/local/nginx/html/ [root@localhost named] # systemctl stop nginx [root@localhost named] # systemctl start nginx

7. Visit the hotlink page again to verify the anti-theft effect.

Thank you for your support!

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