15

I'd like to protect multiple directories with mod_digest with one settings.

Currently I have this /etc/apache2/conf.a/mod-digest_realm-protected.conf

AuthType Digest
AuthName "protected"
AuthDigestDomain /adminer/ /school-project/
AuthDigestNonceLifetime 300

AuthDigestProvider file
AuthUserFile /etc/apache2/.digest
Require valid-user

and this in /etc/apache/sites-available/default

<Directory /var/www/adminer/>
     Include /etc/apache2/conf.a/mod-digest_realm-protected.conf
</Directory>

<Directory /var/www/school-project/>
     Include /etc/apache2/conf.a/mod-digest_realm-protected.conf
</Directory>

Is there a way to have this setting in a single config file? I tried something like this

<Directory /var/www/(adminer/school-project)/>
   ... auth_digest settings
</Directory>

but it doesn't work.

Hologos
  • 397
  • 3
  • 11

2 Answers2

13

try this

<Directory /var/www/>
   ... auth_digest settings
</Directory>

Regex can be used with Directory directive.
http://httpd.apache.org/docs/current/en/mod/core.html#directory

If you just want to protect some of them, I think this should work.

<Directory ~ "(adminer|school-project)"/>
   ... auth_digest settings
</Directory>
Sacry
  • 535
  • 4
  • 9
4

DirectoryMatch also works

<DirectoryMatch ^/var/www/(adminer|school-project)>
...
</DirectoryMatch>
Ray Chakrit
  • 404
  • 5
  • 7