How to configure Nginx anti-theft chain

10-25-2023

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

If the topology diagram:


Referer function in hypertext transfer protocol

Referer:null means that the requester accesses directly.

Referer:blocked is generally added for firewall devices.

Referer:url indicates the indirect access that the host in the url tells the requester.

In the picture, jpg.good.com is obviously a server dedicated to storing pictures by users, while www.good.com is a web server. As can be seen from the domain name, it must be a company, with the following conditions:

1. Only users visiting www.good.com are allowed to visit jpg.good.com as a link (the host content in (referer:url is www.good.com).

2. Reject referer:null (indicating that the requester has direct access).

3. Prevent stealing links (deny users access to jpg.good.com as links; Referer: the host content in the URL is not www.good.com)

Modify the hosts record of three machines as follows

Test.html created in apache default directory /var/www/html is as follows:

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

Read the configuration file /etc/init.d/nginx reload again (restarting the service restart is also acceptable).

Add pictures in/good/a.jpg.

Clients use browsers to access http://www.good.com/test.html.

Grab a bag on nginx

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

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us