Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apache global basic auth

I have apache web server with several virtualhosts

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

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 ?

like image 660
Pydev UA Avatar asked Feb 14 '12 05:02

Pydev UA


1 Answers

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.

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.

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.

like image 124
regilero Avatar answered Nov 24 '22 05:11

regilero