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

How to configure Nginx hotlink protection

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to configure Nginx hotlink protection". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to configure Nginx hotlink protection.

For the sake of service performance, we usually store html static resources on multiple services according to different types.

If the topology diagram:

The role of referer in Hypertext transfer Protocol

Referer:null indicates that the requestor directly accesses

Referer:blocked is generally added for firewall devices

Referer:url represents the indirect access told by the host in the url to the requestor

In the figure, jpg.good.com is obviously a server for specialized users to store pictures, while www.good.com is a web server. You can see from the domain name that it must be a company. Conditions:

1. Only users who access www.good.com are allowed to access jpg.good.com as a link (host content in referer:url is www.good.com)

2. Reject referer:null (which means direct access by the requestor) refuse.

3. Prevent stolen links (deny users access to jpg.good.com as links; host content in referer:url is not www.good.com)

Modify the hosts record of the three machines to

The test.html content created under the default directory / var/www/html of apache is as follows:

Nginx main configuration file vi / etc/nginx/nginx.conf

Reread the configuration file / etc/init.d/nginx reload (restart the service restart is also possible)

Add pictures to / good/a.jpg

The client uses a browser to access http://www.good.com/test.html

Grab the bag on nginx

The client gets the picture and explains it in the browser.

At this point, I believe you have a deeper understanding of "how to configure Nginx hotlink protection". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report