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.
Statement: Blogs are only for sharing information and are not recommendations. Websites do not participate in transactions and are not intermediaries. The content only represents personal views and is not authoritative. Readers should consider it and take their own risks! Every penny and every commodity is still the eternal truth. Juvenile readers (including physical and psychological) should visit this website with their guardians! This article is written by( Zhao Rong )Original compilation, reprint, please keep the link: Simple method of LNMP picture anti-theft chain The code is not easy, please do not copy or paste! About using: This website mainly shares server and VPS information, and does not provide any product sales or purchase. All visitors please purchase and use products within the scope of national laws and regulations. QQ group discussion: 683851361 About safety: Any IDC has the possibility of going bankrupt and running away. The host line is even more uncontrollable. Monthly payment and backup are your best choices. Please keep good and regular backup habits