我有一个 Apache 服务器,目前,我需要阻止除特定人群之外的所有人的访问。我认为,最简单的方法是拒绝所有流量的访问,然后只允许选定的几个 IP 地址。从我在网上找到的内容来看,这种配置应该可以解决问题。
这是 /etc/apache2/sites-available/000-default.conf 的全部内容:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
Order allow,deny
Deny from all
Allow from my.ip.add.res
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
然而,当我测试它时,我从任何地方得到 403'd,包括允许的“my.ip.add.res”IP 地址。
我花了很多时间在谷歌上搜索,但据我所知,这应该可以完美运行。不知道为什么不是。我错过了一些明显的东西吗?
Col*_*olt 12
如果您使用的是 Apache 2.4,请确保您加载authz_core
模块,
删除:
Order allow,deny
Deny from all
Allow from my.ip.add.res
Run Code Online (Sandbox Code Playgroud)
并且,代替已删除的指令,
插入:
Require ip xxx.xxx.xxx.xxx
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 Apache 2.2,请确保您加载authz_host
模块,
删除:
Order allow,deny
Deny from all
Allow from my.ip.add.res
Run Code Online (Sandbox Code Playgroud)
并且,代替已删除的指令,
插入:
Order Deny,Allow
Deny from all
Allow from xxx.xxx.xxx.xxx
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
35489 次 |
最近记录: |