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

你可能感兴趣的文章
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NMF(非负矩阵分解)
查看>>
nmon_x86_64_centos7工具如何使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.7 Parameters vs Hyperparameters
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>