apache全局基本身份验证

问题描述:

我有带有多个虚拟主机的apache网络服务器

I have apache web server with several virtualhosts

我希望它们全部都属于基本授权(AuthType Basic)

I would like all of them be behind basic authorization (AuthType Basic)

但是-看来Auth伪指令仅适用于<Location><Directory>(在Virtualhost部分中)

But - it seems the Auth derective works only for <Location> and <Directory> (inside Virtualhost section)

是否可以同时为所有虚拟主机全局设置基本身份验证?

is there a way to set basic auth globally for all virtual hosts at once ?

在全局配置(在Debian上为httpd.conf或apache2.conf)中设置的任何<Directory><Location>都将适用于所有VirtualHost,因为 共享> global 配置.

Any <Directory> or <Location> set in global configuration (httpd.conf or apache2.conf on Debian) will apply for all VirtualHosts, as a global configuration is shared by definition.

共享一个<Directory>位置非常困难,因为您的VirtualHosts可能具有不同的DocumentRoot.但是<Location />是一个很好的目标,您所有的虚拟主机都将具有'/'网址.

It's quite hard to share a <Directory> location, as you may have different DocumentRoot for your VirtualHosts. But <Location /> is a good target, all your Virtualhosts will have a '/' url.

因此,如果将其放在全局定义的<Location />中,它将起作用,除非一个VirtualHost上的<Location />使用某种指令删除Auth.

So, if you put that in a <Location /> in the global definition it will work, unless a <Location /> on one VirtualHost is using some directive to remove the Auth.