我正在使用Fedora 30上的Apache .conf文件。
在/etc/httpd/conf/httpd.conf中,有:
<Directory />
AllowOverride none
Require all denied
</Directory>
还有:
DocumentRoot "/var/www/html"
这意味着“本地主机”从此“ / var / www / html”库开始。
问题1:在目录Root处于较低级别时,目录“ /”的“要求所有被拒绝”的用途是什么(因此服务器将不会在高层存储库中提供任何文件)?
httpd.conf的末尾有:
IncludeOptional conf.d/*.conf
因此,我在“ /etc/httpd/conf.d”中创建了personal.conf;在我里面设置:
<Directory "/var/www">
AllowOverride None
Require all denied
</Directory>
我重新启动Apache(systemctl重新启动httpd.service),但是localhost / index.html(aka“ DocumentRoot” /index.html或“ /var/www/html"/index.html)仍然可用。
好像在httpd.conf中的该指令是优先的:
<Directory "/var/www/html">
Require all granted
</Directory>
问题2:那么在更高级别的存储库上使用“需要全部拒绝”是什么?
谢谢您的帮助:)
问题1:在目录Root处于较低级别时,目录“ /”的“要求所有被拒绝”的用途是什么(因此服务器将不会在高层存储库中提供任何文件)?问题2:那么在更高级别的存储库上使用“需要全部拒绝”是什么?
如果Require all denied
不存在,则服务器可以轻松地为文档根目录下的文件提供服务,您只需在服务器中进行少量配置即可。例如,假设Alias
喜欢
Alias /etc /etc
这将允许您从http://localhost/etc/passwd或其他敏感内容中读取密码文件。使用默认配置,您将需要一个显式覆盖,例如
<Directory /etc> Require all granted </Directory>
为此。指令
<Directory /> AllowOverride none Require all denied </Directory>
用于防止在/var/www/html
目录下的任何访问,作为一种安全机制(“限制尽可能严格”。)
现在是问题2;让我们想象一个房子:室外[门1]大厅[门2]走廊[门3]客厅。
在/etc/httpd/conf/httpd.conf中,我关闭了房子的前门[1号门
<Directory />
AllowOverride none
Require all denied
</Directory>
我打开了大厅和走廊之间的门[门2]
<Directory "/var/www"> AllowOverride None # Allow open access: Require all granted </Directory>
我打开走廊和客厅之间的门[3号门]
<Directory "/var/www/html"> AllowOverride None Require all granted </Directory>
然后在“ /etc/httpd/conf.d”中的personal.conf文件中我关闭大厅和走廊之间的门[2号门]]:
<Directory "/var/www"> AllowOverride None Require all denied </Directory>
(可访问localhost / index.html或/var/www/html/index.html)而[2号门]已关闭?] >>我需要明确:为什么仍可访问客厅
<Directory "/var/www/html"> AllowOverride None Require all denied </Directory>
in personal.conf要获取“禁止您没有访问此资源的权限。”消息...
再次感谢。