防盗链配置

2019-08-21 22:57 阅读 161 views 次 评论 0 条

#SECURITY-START 防盗链配置
location ~ .*\.(jpg|jpeg|gif|png|js|css)$
{
expires 30d;
access_log off;
valid_referers none blocked test1.myie9.com;
if ($invalid_referer){
return 404;
}
}

 

server
{
listen 80 default_server;
server_name test1.myie9.com test2.myie9.com;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/test1.myie9.com;

#SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
#error_page 404/404.html;
#SSL-END

#ERROR-PAGE-START 错误页配置,可以注释、删除或修改
error_page 404 /404.html;
error_page 502 /502.html;
#ERROR-PAGE-END

#PHP-INFO-START PHP引用配置,可以注释或修改
#SECURITY-START 防盗链配置
location ~ .*\.(jpg|jpeg|gif|png|js|css)$
{
expires 30d;
access_log off;
valid_referers none blocked test1.myie9.com;
if ($invalid_referer){
return 404;
}
}
#SECURITY-END
include enable-php-72.conf;
#PHP-INFO-END

#REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
include /www/server/panel/vhost/rewrite/test1.myie9.com.conf;
#REWRITE-END

#禁止访问的文件或目录
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
{
return 404;
}

#一键申请SSL证书验证目录相关设置
location ~ \.well-known{
allow all;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
error_log off;
access_log off;
}

location ~ .*\.(js|css)?$
{
expires 12h;
error_log off;
access_log off;
}
access_log /www/wwwlogs/test1.myie9.com.log;
error_log /www/wwwlogs/test1.myie9.com.error.log;
}

 

[root@AY140704175917183728Z ~]# more /www/server/nginx/conf/enable-php-72.conf

        location ~ [^/]\.php(/|$)

        {

            try_files $uri =404;

            fastcgi_pass  unix:/tmp/php-cgi-72.sock;

            fastcgi_index index.php;

            include fastcgi.conf;

include pathinfo.conf;

        }

[root@AY140704175917183728Z ~]# more /www/server/nginx/conf/pathinfo.conf

set $real_script_name $fastcgi_script_name;

if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {

set $real_script_name $1;

set $path_info $2;

}

fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;

fastcgi_param SCRIPT_NAME $real_script_name;

fastcgi_param PATH_INFO $path_info;

版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:防盗链配置 | 蚂蚁浏览器看点
分类:电脑技术 标签:

发表评论


表情