need: Usually, sites want to prevent videos and pictures on their websites from being stolen. After all, video traffic costs a lot of money (rich people don’t have to consider this). 1. Straight to the point, first upload the nginx configuration file 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; } } 2. Interpretation of the core configuration file of anti-hotlink 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 links, as follows, otherwise enter $invaild_refere and return 403 forbidden. 1. none "Referer" source header is empty 2. blocked The "Referer" source header is not empty, but the value is deleted by a proxy or firewall, and none of the values start with http:// or https://. 3. server_names The "Referer" source header contains the current server_names (current domain name) 3. Simulation Case Test 1. Add --referer to simulate reference and see the result is 403 directly. This proves 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 Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. You may also be interested in:
|
<<: Installation tutorial of mysql 5.7 under CentOS 7
>>: js to achieve simple calendar effect
Preface MySQL is a relational database with stron...
remember: IDE disk: the first disk is hda, the se...
Some web pages may not look large but may be very...
Table of contents 1. Scene loading 2. Find Node 1...
Table of contents Preface Discover the cause Cust...
Mac comes with Apache environment Open Terminal a...
Next, I will create two tables and execute a seri...
Note 1: Solve the problem of slow connection to M...
Table of contents Overview 1. Develop the require...
Table of contents Overview Code Implementation Su...
In development projects, we can monitor SQL with ...
Table of contents 1. Digital Operation (1) Genera...
The previous article introduced the implementatio...
Table of contents 1. Simple mounting of persisten...
I don't expect to be an expert DBA, but when ...