Is 'Include /path/to/*/live.conf' possible with Apache?
apache2 does not support wildcards in includes. However, you could arrange it a bit in the following manner:
- create some directory for your configs (such as /etc/apache2/myconfigs)
- symlink your configuration dynamically to apache2:
rm -f /etc/apache2/myconfigs/* for i in $(find /var/www/vhosts/*/live.conf); do \ tempfn=$(echo $i|cut -d/ -f5-6|sed s,/,_,); \ ln -s $i /etc/apache2/myconfigs/$tempfn.conf \ done
- add a "Include /etc/apache2/myconfigs" in your apache2.conf
Note: on cut, i used -f5-6 for delimiter joining (to provide something like site1.com_live.conf symlink name), but you might have to adjust that according to your own fs path. Note on note: the above is for bash, might need adapting for other shells.
I've tested, it through the below error when checking syntax:
httpd: Syntax error on line 211 of /etc/httpd/conf/httpd.conf: Wildcard patterns not allowed in Include /etc/httpd/*/pr.conf
According to the documentation, from version 2.0.41, it supports the wildcard matching follow shell-style (fnmatch()). But it seems that it only works with the file (or the last component in the path), not the directory.
Testing with python, it returns true:
In [1]: import fnmatch
In [2]: fnmatch.fn
fnmatch.fnmatch fnmatch.fnmatchcase
In [2]: fnmatch.fnmatch('/etc/httpd/site1.com/live.conf','/etc/httpd/*/live.conf')
Out[2]: True