#配置生效
server{
include /opt/www/nginx/conf/dropsql;
}
cat /opt/www/nginx/conf/dropsql
# Block common exploits
set $block_common_exploits 0;
#过滤alert
if ($query_string ~ .*alert.*) {
set $block_common_exploits 1;
}
#过滤script
if ($query_string ~ .*script.*) {
set $block_common_exploits 1;
}
#返回603
if ($block_common_exploits = 1) {
return 603;
}
本文介绍了一种使用Nginx配置文件来阻止常见网络攻击的方法。通过设置特定的正则表达式,Nginx可以识别并拦截包含'script'或'alert'等恶意字符串的请求,有效防御常见的XSS攻击。当检测到这些恶意请求时,服务器将返回603错误码。
1731

被折叠的 条评论
为什么被折叠?



