httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emanuele Bastianelli <manu.re...@gmail.com>
Subject [users@httpd] Apache 2.4 mod_macro does not instantiate all the defined Macros
Date Mon, 12 Sep 2016 10:42:06 GMT
I'm using Apache 2.4 with mod_macro. According to the documentation
<https://httpd.apache.org/docs/2.4/mod/mod_macro.html>, it is possible to
instantiate several macro, in order to not to rewrite the same block of
configuration. Example from the documentation:

<Macro VHost $name $domain>
  <VirtualHost *:80>
    ServerName $domain
    ServerAlias www.$domain

    DocumentRoot "/var/www/vhosts/$name"
    ErrorLog "/var/log/httpd/$name.error_log"
    CustomLog "/var/log/httpd/$name.access_log" combined
  </VirtualHost>
</Macro>

Use VHost example example.com
Use VHost myhost hostname.org
Use VHost apache apache.org

I did the same for my server, with the following VirtualHost configuration
file

<Macro VHost $request_uri>
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        DBDriver mysql
        DBDParams "host=localhost port=3306 user=myself
pass=myselfpass dbname=apacheauth"
        DBDMin  2
        DBDKeep 4
        DBDMax  10
        DBDExptime 300

        <Location $request_uri>
          AuthName $request_uri
          AuthType Digest
          AuthDigestAlgorithm MD5
          AuthDigestDomain /
          AuthDigestProvider dbd
          AuthDBDUserRealmQuery "SELECT MD5(password) FROM password
WHERE username = %s AND realm = %s"
          Require valid-user
        </Location>

    </VirtualHost>
</Macro>

Use VHost /test
Use VHost /anothertest

The prolem is that the configuration work when I try to access
www.mysite.com/test, asking me for the credential, and does not work when I
try to access www.mysite.com/anothertest, showing me the current page
without asking the credential. It seems like the server instantiates a
VirtualHostonly for the first Use directive, skipping all the following.


Best

EB

Mime
View raw message