0
点赞
收藏
分享

微信扫一扫

Nginx 跨域和防盗链配置

互联网码农 2021-09-25 阅读 69
Nginx

1 跨域配置

#允许跨域请求的域,*代表所有
add_header 'Access-Control-Allow-Origin' *;
#允许带上cookie请求
add_header 'Access-Control-Allow-Credentials' 'true';
#允许请求的方法,比如 GET/POST/PUT/DELETE
add_header 'Access-Control-Allow-Methods' *;
#允许请求的header
add_header 'Access-Control-Allow-Headers' *;

2 防盗链配置

#对源站点验证
valid_referers *.p2pi.cn;
#非法引入会进入下方判断
if ($invalid_referer) {
return 404;
}

3 相关信息

  • 博文不易,辛苦各位猿友点个关注和赞,感谢
举报

相关推荐

0 条评论