最近在解决公司host头攻击漏洞问题,使用nginx(1.8.0)做转发,HTTP host头攻击的技术 这篇文章给了我思路。但是使用其nginx解决方案中的方法二时nginx.conf无法reload ,报invalid condition "$http_Host“这个错误。
最终查找网上的文章,发现可能是if中的表达式有问题,最终通过修改表达式的判断语句解决了该问题。
原代码(摘自HTTP host头攻击的技术 方法二)
server {
server_name 192.168.0.171;
listen 8888;
if ($http_Host !~*^192.168.0.171:8888$)
{
return 403;
}
include /etc/nginx/default.d/*.conf;
location / {
root /www/dvwa;
index index.php index.html index.htm;
}
}
修改后的代码:
server {
server_name 192.168.0.171;
listen 8888;
if ($http_Host != '192.168.0.171:8888')
{
return 403;
}
include /etc/nginx/default.d/*.conf;
location / {
root /www/dvwa;
index index.php index.html index.htm;
}
}
参考文章: