Lease of cloud servers and independent servers in Hong Kong/South Korea

Simple method of LNMP picture anti-theft chain

 Proprietary computer room/advanced anti DDoS server/advanced anti DDoS VPS/American advanced anti DDoS/Los Angeles VPS/Los Angeles advanced anti DDoS server

I saw a friend asking in QQ group yesterday LNMP In fact, the military brother has already answered the question about how to prevent chains from being stolen in the environment. Here I will share it with you and take a note at the same time.

Since nginx does not support. htaccess, it is impractical to prevent it directly from this aspect. We need to modify the configuration file to solve this problem.

First, we find the conf file of the domain name that needs the anti leech. The path is/usr/local/nginx/conf/vhost/, such as zrblog.net.conf

It's better to back it up first, so as not to make mistakes and directly cover it back. This is a good habit!!!

Find the following section:

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

Change it to:

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
valid_referers none blocked www.zrblog.net zrblog.net;
if ($invalid_referer) {
rewrite ^/ http:// vpsaa .com/404.jpg;
#return 404;
}
expires 30d;
}

Please revise the above content according to your own situation. I will give you a basic explanation here.

The first line gif | jpg | jpeg | png... These are the file types you need to prevent piracy. You can add some suffix types;

The third line is the domain name of your website, that is, the domain name released. If there are multiple domains, please add them, and pay attention to the blank space;

The fifth line is the picture seen by the pirate chain. A 404.jpg is returned. The source address of the picture must be able to be linked outside. Otherwise, the picture seen by others is just a XX.

After that, save it, upload it to the original location, and then restart lnmp to make it effective.

/root/lnmp restart

In addition, a friend asked how to prevent collection. It seems that there is no particularly effective method for this problem at present. It is suggested that you can study it from the system level, such as the limitation of iptables rules.

QQ group: 683851361, contact me: zrblog@qq.com

 Cheap VPS/$10 VPS/Los Angeles, San Jose and other computer rooms