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
Preface In the previous interview process, when a...
Table of contents 1. Function Binding 2. With par...
The previous article introduced a detailed exampl...
In design work, I often hear designers participati...
Table of contents Configure node.js+nvm+npm npm s...
Table of contents SSH protocol SSH Connection pro...
The default firewall of CentOS7 is not iptables, ...
Table of contents Preface How does antd encapsula...
JBoss uses Tomcat as the Web container, so the co...
Table of contents Preface Summary of audio and vi...
Simple XHTML web form in web design 5. Technique ...
Docker image download is stuck or too slow I sear...
Preface The effect problems used in personal actu...
In the development environment, the vue project i...
It is provided in the form of WeChat components. ...