Nginx anti-leech, Nginx access control, Nginx parsing php related configuration, Nginx proxy

Nginx anti-leech:

vim /usr/local/nginx/conf/vhost/test.com.conf = default virtual host configuration anti-leech

#防盗链核心配置
location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls)$    =表示匹配文件格式
{
    expires 7d;     = 保存7天
    valid_referers none blocked server_names  *.test.com ;     = 匹配域名
    if ($invalid_referer) {
        return 403;   = 域名匹配不成功返回403
    }
    access_log off;
}

After configuration -t && -s reload

[root@aming-01 test.com]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@aming-01 test.com]# /usr/local/nginx/sbin/nginx -s reload

Test anti-leech:

[root@aming-01 test.com]# curl -e "http:www.test.com/1.txt" -x127.0.0.1:80 test.com/1.gif -I   =测试防盗链需要指定 -e 然后格式必须使用 http 开头
HTTP/1.1 200 OK    = 200状态码说明Ok
Server: nginx/1.12.1
Date: Thu, 26 Apr 2018 14:04:56 GMT
Content-Type: image/gif
Content-Length: 21
Last-Modified: Thu, 26 Apr 2018 13:48:21 GMT
Connection: keep-alive
ETag: "5ae1d8a5-15"
Expires: Thu, 03 May 2018 14:04:56 GMT
Cache-Control: max-age=604800
Accept-Ranges: bytes

 

 

Nginx access control:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324922904&siteId=291194637