Nginx expires module and anti-theft chain

Source: Internet
Author: User
Keywords Nginx anti-theft chain expires
Tags aliyun anti- anti-theft anti-theft chain blocked data default file

Nginx expires

1. Expires according to file type

# ADD Expires header for static content
Location ~*. (js|css|jpg|jpeg|gif|png|swf) $ {
if (-F $request _filehttp://www.aliyun.com/zixun/aggregation/11696.html ">name") {
Root/data/www/wwwroot/bbs;
Expires 1d;
Break;
}
}

2, according to the judgment of a directory

# Serve static files
Location ~ ^/(images|javascript|js|css|flash|media|static)/{
Root/data/www/wwwroot/down;
Expires 30d;
}

Nginx anti-theft Chain

1. For different file types

#Preventing hot linking of images and other file types
Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip) $ {
Valid_referers None blocked Server_names *.linuxtone.org linuxtone.org http://localhost;
if ($invalid _referer) {
Rewrite ^/http://www.linuxtone.org/images/default/logo.gif;
# return 403;
}
}

2. For different catalogs

location/img/{
root/data/www/wwwroot/bbs/img/;
Valid_referers None blocked Server_names *.linuxtone.org http://localhost baidu.com;
if ($invalid _referer) {
Rewrite ^/http://www.linuxtone.org/images/default/logo.gif;
#return 403;
}
}

3. With the realization of anti-theft chain and expires methods

#Preventing hot linking of images and other file types
Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip) $ {
Valid_referers None blocked Server_names *.linuxtone.org linuxtone.org http://localhost;
if ($invalid _referer) {
Rewrite ^/http://www.linuxtone.org/images/default/logo.gif;
}
Access_log off;
Root/data/www/wwwroot/bbs;
Expires 1d;
Break;
}

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.