apache 我如何在httpd.conf中允许从一个范围内的单个IP访问,而不允许其他地址,同时允许所有其他地址?

shyt4zoc  于 6个月前  发布在  Apache
关注(0)|答案(1)|浏览(70)

我试图允许整个子网的一个地址访问目录,同时禁止其他地址访问目录,并允许所有其他地址访问目录
我是否必须将这些命令分解为单独的块,如;

<Directory directory-path>   
    <RequireAny>
    <RequireAll>
       Require ip 126.26.110.1
    </RequireAll>
    <RequireAll>
       Require all granted
       Require not ip 126.26.110.0
    </RequireAll>
    </RequireAny>
<Directory>

字符串
我只是想确保我在正确的轨道上,并将非常感谢一些反馈

dfuffjeb

dfuffjeb1#

有趣的例子。假设你的意思是不允许整个子网,但允许任何其他子网的ip。
默认为Any,因此除非必要,否则不应指定它。
我认为你应该去(在我的测试中为我工作):

<Directory /path/to/whatever>
       Require ip 126.26.110.1
       <RequireAll>
           Require not ip 126.26.110
           Require all granted
       </RequireAll>
</Directory>

字符串
这样,它要么是第一选择,要么是第二组选择,四舍五入为requireall。

相关问题