In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to configure hotlink protection in Nginx. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
First, go straight to the nginx configuration file first.
Server {listen 80; server_name www.test.com; root / data/web/; index index.php index.html; access_log / data/logs/nginx/biao.madacode.access.log main; location / {root / home/data/;} error_page 404 / usr/local/nginx/html/404.html Location ~. *\. (wma | wmv | asf | mp3 | mp4 | mmf | zip | rar | jpg | gif | png | swf | flv) ${valid_referers none blocked server_names * .test.com http://IP; if ($invalid_referer) {return 403;} expires 24h; access_log off;} location ~ /\. {deny all;}}
Second, explanation of hotlink protection core configuration file
Location ~. *\. (wma | wmv | asf | mp3 | mp4 | mmf | zip | rar | jpg | gif | png | swf | flv) ${valid_referers none blocked server_names * .test.com http://IP; if ($invalid_referer) {return 403;} expires 24h; access_log off;}
Vaild_referers valid reference connection, as follows, otherwise enter $invaild_refere and return 403 forbiden.
1. None
If the header of the "Referer" source is empty
2. Blocked
The "Referer" source header is not empty, but the values are deleted by the proxy or firewall, none of which starts with http:// or https://.
3. Server_names
The "Referer" source header contains the current server_names (current domain name)
Third, simulated case test
Add-- referer simulation reference, see the result directly 403. Prove that the above configuration is OK.
[root@test] # curl-- referer http://baidu.com-I http://www.test.com/temp/T19254/20190820/video_out_out/1/0011.mp4 HTTP/1.1 403 Forbidden Server: Tengine Date: Wed, 21 Aug 2019 09:54:44 GMT Content-Type: text/html Content-Length: 639 Connection: keep-alive
Thank you for reading! This is the end of the article on "how to configure hotlink protection in Nginx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.