Mic*_*man 7 apache-2.4 ubuntu-14.04
默认的 apache.conf(ubuntu 服务器)包含以下块:
# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
# .... other items removed for brevity
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
Run Code Online (Sandbox Code Playgroud)
我对这个指令的解释是 apache 将允许对/usr/share
文件夹中的项目进行 Web 浏览。但是如果我尝试浏览并/usr/share/
查看项目中的任何内容?
如何浏览/usr/share 中的内容?
例如,如果我将浏览器指向localhost/synaptic/html/index.html
我收到 404 not found 错误
如果 apache 允许浏览此目录 - 我是否需要将其锁定在生产服务器上?
您需要将 URL 路径映射到 /usr/share。最简单的方法是使用 Alias 指令,例如:
Alias /share /usr/share
Run Code Online (Sandbox Code Playgroud)
然后http://localhost/share/synaptic
将映射到/usr/share/synaptic
. 请参阅Alias 的文档。
/usr/share 中的所有文件对于非 root 用户来说都应该是不可写的,包括 Apache 用户 www-data。它们可能也是全世界可读的。因此,按照上述方式为它们提供服务应该没问题,没有任何额外的限制。但是,如果 /usr/share 中有您不希望 Apache 用户看到的公共文件,您可以使用Require all deny
指令来阻止对这些文件的访问。
归档时间: |
|
查看次数: |
6294 次 |
最近记录: |