1. Principle of Hotlinking1.1 Web page preparationWeb source host (192.168.153.20) configuration cd /usr/local/nginx/html Transfer the preview.jpg image file to the /usr/local/nginx/html directory vim index.html ...... <img src="preview.jpg"/> </body> </html> echo "192.168.153.20 www.wt.com" >> /etc/hosts echo "192.168.153.10 www.abc.com" >> /etc/hosts Hotlink website host (192.168.153.20) configuration In order to distinguish it from the nginx service of the source host, the hotlink host can use the general wed service yum install -y httpd vim /var/www/html/index.html <html><body><h1>Hello! </h1> <img src="http://www.wt.com/preview.jpg"/> </body></html> echo "192.168.153.20 www.wt.com" >> /etc/hosts echo "192.168.153.10 www.abc.com" >> /etc/hosts systemctl restart httpd 1.2 Browser access verification 2. Configure anti-hotlinking2.1 Modify the configuration filevim /usr/local/nginx/conf/nginx.conf http { ...... server { ...... location ~* \.(jip|gif|swf)$ { valid_referers *.wt.com wt.com; if ( $invalid_referer ) { rewrite ^/ http://www.wt.com/error.png; #return 403; } } ...... } } ~* .(jpg|gif|swf)$ : This regular expression matches case-insensitive files ending with .jpg, .gif or .swf; Transfer the error.png image file to the /usr/local/nginx/html directory 2.2 Browser access verification This is the end of this article about how to configure anti-hotlinking for nginx website services. For more relevant content on anti-hotlinking for nginx website services, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Example of how to set up a multi-column equal height layout with CSS
>>: Vue Page Stack Manager Details
Implementation of transactions The redo log ensur...
Table of contents Seconds_Behind_Master Original ...
Table of contents 1. Concept of array flattening ...
This article shares the specific code of the jQue...
What Beautiful HTML Code Looks Like How to write ...
1. Nginx service foundation Nginx (engine x) is d...
Table of contents 1. What is a directive? Some co...
1. Introduction The telnet command is used to log...
I have introduced it to you before: docker (deplo...
Table of contents 1. Test environment 1.1 Hardwar...
This article shares with you a uniform motion imp...
What is nGrinder? nGrinder is a platform for stre...
This article shares the specific code of Vue usin...
In MySQL, the LOAD_FILE() function reads a file a...
Table of contents 1. filter() 2. forEach() 3. som...