zoukankan      html  css  js  c++  java
  • apache2.4 只允许合法域名访问网站 禁止使用ip、非法域名访问

    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>

  • 相关阅读:
    Linux环境变量$PATH
    grep
    echo命令
    ip命令
    浅析Linux下的/etc/profile、/etc/bashrc、~/.bash_profile、~/.bashrc文件
    shell脚本4种执行方式
    /proc路径
    tr命令
    Linux命令cut
    前端论坛网站知识
  • 原文地址:https://www.cnblogs.com/prettyisshit/p/6129429.html
Copyright © 2011-2022 走看看