IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    apache2.4 只允许合法域名访问网站 禁止使用ip、非法域名访问

    陈华发表于 2021-11-05 15:15:41
    love 0

    1.ip访问
    禁用ip访问 只能对应端口有效
    <VirtualHost *:80>
    ServerName xx.xx.xx.xx
    ServerAlias *
    <Location />
    Order Allow,Deny
    Deny from all
    </Location>
    </VirtualHost>
    <VirtualHost *:8511>
    ServerName xx.xx.xx.xx
    ServerAlias *
    <Location />
    Order Allow,Deny
    Deny from all
    </Location>
    </VirtualHost>

    2.非法域名 本地设置host 将ip绑定为服务器ip
    禁用方法
    在httpd.conf的末尾加上
    这种方法还可以防止使用xx.xx.xx.xx直接访问
    #禁止所有非法域名
    <VirtualHost *:80>
    ServerName xx.xx.xx.xx
    ServerAlias *
    <Location />
    Order Allow,Deny
    Deny from all
    </Location>
    </VirtualHost>

    3.允许访问的域名
    为其添加配置
    <VirtualHost *:80>
    ServerAdmin xx@xx.com
    DocumentRoot “/home/wwwroot/xx”
    ServerName www.xx.com
    ServerAlias *.xx.com
    ErrorLog “logs/www.xx.com-error_log”
    CustomLog “logs/www.xx.com-access_log” common
    <Directory “/home/wwwroot/xx”>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    </VirtualHost>

    自由转载,转载请注明: 转载自WEB开发笔记 www.chhua.com

    本文链接地址: apache2.4 只允许合法域名访问网站 禁止使用ip、非法域名访问 http://www.chhua.com/web-note5616

    随机笔记

    • 20教你制作超级酷的视觉效果的jQuery教程
    • 分享10个视差滚动效果的插件
    • 微信JSAPI支付V3版本
    • PHP获取客户端真实IP地址方法
    • 人声效果的精细处理二(白礼服版)


沪ICP备19023445号-2号
友情链接