Apache - 限制 IP 不起作用
我有一个子域,我只想在内部访问;我试图通过编辑该域的 VirtualHost 块来在 Apache 中实现此目的。有人能看出我哪里出错了吗?注意,我这里的内部IP地址是192.168.10.xxx。我的代码如下:
<VirtualHost *:80>
ServerName test.example.co.uk
DocumentRoot /var/www/test
ErrorLog /var/log/apache2/error_test_co_uk.log
LogLevel warn
CustomLog /var/log/apache2/access_test_co_uk.log combined
<Directory /var/www/test>
Order allow,deny
Allow from 192.168.10.0/24
Allow from 127
</Directory>
</VirtualHost>
谢谢
I've a subdomain that I only want to be accessible internally; I'm trying to achieve this in Apache by editing the VirtualHost block for that domain. Can anybody see where I'm going wrong? Note, my internal IP address here are 192.168.10.xxx. My code is as follows:
<VirtualHost *:80>
ServerName test.example.co.uk
DocumentRoot /var/www/test
ErrorLog /var/log/apache2/error_test_co_uk.log
LogLevel warn
CustomLog /var/log/apache2/access_test_co_uk.log combined
<Directory /var/www/test>
Order allow,deny
Allow from 192.168.10.0/24
Allow from 127
</Directory>
</VirtualHost>
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少
Deny from all
行吗?哦,还有使用了错误的顺序
。引用 mod_access 文档:
You're missing the
Deny from all
line? Oh, and using the wrongorder
.Quoting the mod_access docs:
问题是您的本地网络允许线路。将
Allow from 192.168.10.0/24
替换为Allow from 192.168.10.
(将允许 192.168.10.*)。为了完整起见,请添加
Deny from all
行,以明确您正在阻止其他所有人。The problem is your allow line for the local network. Replace
Allow from 192.168.10.0/24
withAllow from 192.168.10.
(will allow 192.168.10.*).For completeness, add a
Deny from all
line to make it clear that you're blocking everyone else.我想 Directory 标签内的路径应该只是 /
并且请不要忘记重新启动 apache
I suppose the path inside Directory tag should be simply /
and please don't forgot to restart apache