Nginx modified configuration Implementation Picture anti-theft chain

Source: Internet
Author: User

In general, the anti-theft chain is for software downloads and pictures, because the general site does not provide resources to download, so this article is mainly for the image of the anti-theft chain

1, if the whole station picture to do anti-theft chain, at least need an additional domain name to store pointing to the picture. Because if the whole station pictures do a chain of anti-theft, including hotlinking hint picture of all the pictures can not be displayed.

Such cases modify the/usr/local/nginx/conf/nginx.conf file

2, the individual domain name configuration picture anti-theft chain, personal comparison recommendation, one is easy to control, second, you can re-create a domain name on the same server used to store hotlinking hint pictures.

This kind of situation modifies/usr/local/nginx/conf/vhost/your own domain name. conf file

3, you need to prepare a hotlinking hint picture, put on other servers or other domain name (picture you do it, not provided here)

4, found in the configuration file similar to the following location...jpg ... This code, and then change it, I slowly explain

Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
{
Expires 30d;
Access_log off;
Valid_referers None blocked *.slyar.com *.jetfond.com *.youdao.com *.zhuaxia.com *.xianguo.com *.google.cn *.google.com *.google.com.tw *.google.com.sg *.google.com.hk *.bloglines.com image.soso.com bing.com cn.bing.com image.baidu.com *. FeedBurner.com *.feedsky.com;
if ($invalid _referer)
{
Rewrite ^/http://kvm.slyar.com/slyar_hotlinking.png;
}
}

Expires 30d; Client cache time, unrelated hotlinking

Access_log off; Do not log picture access logs, unrelated hotlinking

Valid_referers None blocked ...//allow access to the site of the picture, blocked supports prefix wildcard characters. None need to explain, if you do not know what HTTP refer is, then do not know, if you know, then this none means matching no refer access, popular point is directly with the URL to access, here I write to express permission, You can delete this parameter if you do not allow to see the image directly in the image address.

Rewrite ^/http://kvm.slyar.com/slyar_hotlinking.png; Hotlinking request to jump to a picture or a page, casually

5.: Wq Save exit

6. Reload nginx config file, done

/etc/init.d/nginx Reload

Nginx modified configuration Implementation Picture anti-theft chain

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.