博客
关于我
网站有域名的情况下,禁用通过IP访问网站内容
阅读量:803 次
发布时间:2019-03-25

本文共 867 字,大约阅读时间需要 2 分钟。

不禁用风险 1. 改攻者可以通过直接访问IP绕过CDN、云WAF等云防护措施
2. 攻击者可以将恶意域名解析至服务器IP地址进行仿站,或导致服务器IP因解析恶意域名被查封
3. 改攻击者通过修改host头注入恶意代码至页面中

安全对策

针对上述风险,以下是有效的防护方案:

方案一:Apache服务器

通过特定规则定义仅允许特定域名访问服务器,确保未经授权的IP无法解析域名。

编辑文件路径:`/etc/apache2/ports.conf` 或相应配置文件

添加以下配置至文件末尾:

ServerName 192.168.0.1 # (网站公网IP) Deny from all Allow from 192.168.0.1

重启Apache:

sudo systemctl restart apache2
方案二:Nginx服务器

基于Nginx配置限制访问规则,确保仅限于指定IP或域名访问服务器资源。

编辑文件路径:`/etc/nginx/nginx.conf`

添加以下配置至服务器块:

server { server_name 192.168.0.1; listen 80; access_log off; if ($http_Host !~ 192.168.0.1$) { return 403; } location / { root /www/chuai; index index.php index.html index.htm; } }

重启Nginx:

sudo systemctl restart nginx

此类配置可有效防止恶意域名解析及未经授权IP访问,同时为实际应用场景提供灵活性。

转载地址:http://stoyk.baihongyu.com/

你可能感兴趣的文章
Powershell DSC 5.0 - 参数,证书加密账号,以及安装顺序
查看>>
PowerShell 批量签入SharePoint Document Library中的文件
查看>>
Powershell 自定义对象小技巧
查看>>
pytorch从预训练权重加载完全相同的层
查看>>
PowerShell~发布你的mvc网站
查看>>
PowerShell使用详解
查看>>
Powershell制作Windows安装U盘
查看>>
powershell命令
查看>>
Powershell如何查看本地公网IP
查看>>
pytorch从csv加载自定义数据模板
查看>>
powershell对txt文件的服务器进行ping操作
查看>>
powershell常用
查看>>
PowerShell操作XML遇到的问题
查看>>
PowerShell攻击工具Empire实战
查看>>
PowerShell攻击工具Nishang实战
查看>>
PowerShell攻击工具PowerSploit实战
查看>>
Powershell管理系列(四)Lync server 2013 批量启用语音及分配分机号
查看>>
PowerShell脚本运行完 不要马上关闭用什么命令可以停留窗口窗口
查看>>
PowerShell远程连接到Windows
查看>>
power(8) identity
查看>>