我们其中一个可公开访问的Web服务器使用<Location />块来限制对所有本身的访问。
我有一个特定的目录需要比<Location />提供的更严格的访问限制。
但是,使用<Directory /path/to/dir>是不可能的,因为<Directory>被<Location>覆盖。
我可以做些什么来限制对特定目录的访问,同时在整个Web服务器上保持一个不太严格的访问限制?
不能将<Location />更改为<Directory /path/to/docroot>因为这个Apache作为内部服务器上很多其他networking服务器的反向代理,不能直接从networking外部访问。
根据要求,我们的configuration一点细节:
我们所有的授权和authentication都是通过LDAP完成的。
由于这个Apache是作为许多内部Web服务器的反向代理,我们需要限制对它的全部访问:
<Location /> Order deny,allow Deny from all AuthName [...] AuthType Basic AuthLDAPURL [...] AuthBasicProvider ldap Require ldap-attribute [...] </Location>
文档根目录下的特定目录需要更严格的访问权限。 所以我想到了这个:
<Directory /path/to/dir> Order allow,deny AuthName [...] AuthType Basic AuthLDAPURL [...] AuthBasicProvider ldap Require ldap-attribute [...] Require ldap-attribute [...] Require ldap-attribute [...] </Directory>
但是,这不起作用,因为<Location>部分在<Directory>部分之后被合并(参见这里 )。
所以,尽pipe我已经为目录写了一个<Directory>部分,但是我希望对这些指令有更严格的访问权限,这些权限被<Location />的指令所覆盖,允许访问更多的用户。
如何使用<Location /location/to/restrict/> ?
无论如何,它们本身不会“覆盖”。 他们合并。 欲了解更多信息,请看这里 。
如果您仔细考虑将要合并的内容,仍然可以使用<Directory> 。 <Location>应用最后一个,但是如果它没有指定任何访问控制,它不会取消你在<Directory> 。
Order deny,allow <Location /> # No permission settings here; no allow or deny. # Will be allowed by default because of the Order. ... </Location> <Directory /location/to/restrict/> Deny from all Allow from 10.0.0.0/8 ... </Directory>