Apache: one setting for multiple directories

I would like to protect multiple directories with mod_digest with a single setting.

I currently 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 is 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 set this parameter in a single configuration file? I tried something like this

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

but that will not work.

+6
source share
1 answer

try it

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

Regex can be used with the 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> 
+7
source

Source: https://habr.com/ru/post/947162/


All Articles