博客
关于我
网站有域名的情况下,禁用通过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/

你可能感兴趣的文章
NoClassDefFoundError: org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata
查看>>
node
查看>>
node exporter完整版
查看>>
node HelloWorld入门篇
查看>>
Node JS: < 一> 初识Node JS
查看>>
Node JS: < 二> Node JS例子解析
查看>>
Node Sass does not yet support your current environment: Linux 64-bit with Unsupported runtime(93)解决
查看>>
Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime(72)
查看>>
Node 裁切图片的方法
查看>>
node+express+mysql 实现登陆注册
查看>>
Node+Express连接mysql实现增删改查
查看>>
node, nvm, npm,pnpm,以前简单的前端环境为什么越来越复杂
查看>>
Node-RED中Button按钮组件和TextInput文字输入组件的使用
查看>>
vue3+Ts 项目打包时报错 ‘reactive‘is declared but its value is never read.及解决方法
查看>>
Node-RED中Slider滑杆和Numeric数值输入组件的使用
查看>>
Node-RED中Switch开关和Dropdown选择组件的使用
查看>>
Node-RED中使用exec节点实现调用外部exe程序
查看>>
Node-RED中使用function函式节点实现数值计算(相加计算)
查看>>
Node-RED中使用html节点爬取HTML网页资料之爬取Node-RED的最新版本
查看>>
Node-RED中使用JSON数据建立web网站
查看>>