首页 > 解决方案 > 不需要 ip 不会阻止 apache centos 服务器上的 IP 地址

问题描述

我试图阻止我的服务器的 IP 并阻止他们能够加载我的网站,我已将他们的 IP 添加到httpd.conf文件中并成功重新启动 httpd,但在尝试加载网站后,我仍然能够访问该网站,我肯定不会错过一些明显的东西吗?

我究竟做错了什么?

#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
    AllowOverride none
    Require all denied
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/var/www/MY-SITE/dist"

#
# Relax access to content within /var/www.
#
<Directory "/var/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    <RequireAll>
      Require all granted
      Require not ip X.X.X.X
    </RequireAll>

    # Header set Access-Control-Allow-Origin "*"
</Directory>

在此处输入图像描述

标签: apachecentoshttpd.conf

解决方案


在这里

<Directory "/var/www">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options FollowSymLinks

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All

#
# Controls who can get stuff from this server.
#
<RequireAll>
  Require all granted
  Require not ip X.X.X.X
</RequireAll>

# Header set Access-Control-Allow-Origin "*"

您需要像这样更改目录路径

<Directory "/var/www/MY-SITE/dist">

然后尝试一下。谢谢你


推荐阅读