Nginx日志切割,跨域配置,防盗链配置
add_header 'Access-Control-Allow-Origin' $http_origin;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,web-token,app-token,Authorization,Accept,Origin,Keep-Alive,User-Agent,X-Mx-ReqToken,X-Data-Type,X-Auth-Token,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
server {
listen 80;
server_name www.imcati.com refer-test.imcati.com;
root /usr/share/nginx/html;
location ~*\.(gif|jpg|jpeg|png|bmp|swf)$ {
valid_referers none blocked www.imcati.com;
if ($invalid_referer) {
return 403;
}
}
}
valid_referers: 指定资源访问是通过以下几种方式为合法,即白名单。
none:允许缺失的头部访问。
blocked:允许referer没有对应值的请求。
server_names:若referer站点域名与server_name中本机配的域名一样允许访问。
本文来自博客园,作者:萧长风,转载请注明原文链接:https://www.cnblogs.com/xiejunlampard/p/14680175.html