Varnish common two application examples share

Source: Internet
Author: User
Keywords application example varnish
Tags aliyun anti- anti-theft anti-theft chain application application example applications applied

Varnish can be applied in many ways, and as the version of the upgrade, its functional applications are increasing, here only a few applications widely, http://www.aliyun.com/zixun/aggregation/17547.html "> Powerful application examples. Since the configuration format of the varnish has been described in detail earlier, the configuration code for the corresponding module is given here, along with the relevant instructions.

1, the use of varnish to achieve the picture anti-theft chain

Image anti-theft chain function for large web site operation is very important, a variety of Web servers, such as Apache and Nginx can easily realize the image anti-theft chain function. Using varnish to implement this function is also very simple, just add the following configuration to the VCL_RECV function of the configuration file.

if (req.http.referer ~ "http://.*") {
if (!) ( Req.http.referer ~ "Http://.*ithov.com"
|| Req.http.referer ~ "Http://.*google.com"
|| Req.http.referer ~ "http://.*yahoo.cn" et
|| Req.http.referer ~ "http://.*google.cn"
))  {
Set req.http.host = "www.ithov.com";
Set req.url = "/templets/default/images/logo.gif";
}
return (lookup);
}

In this configuration, with a built-in variable req.http.referer, anti-theft chain is through the referer to achieve. In fact, Referer is a part of the HTTP header, when the browser to send a request to the Web server, usually with a referer logo, to tell the server request is from which page chain received from the server according to this identity can information sources, and then the corresponding processing.

The meaning of this configuration is: Varnish the server to receive or send the request to judge, if the Referer identity exists, and Referer identity does not match any of the following domain name list, the request is redirected to the www.ithov.com domain name/templets/ Default/images/logo.gif the picture and performs a lookup operation on a request to find a matching domain name.


Related Article

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.