So I want dynamic VirtualHost creation like so:
LoadModule vhost_alias_module modules/mod_vhost_alias.so
<VirtualHost *:80>
VirtualDocumentRoot "/usr/local/apache2/htdocs/%1"
ServerName %1.domain.com
ServerAlias *.domain.com
ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php.domain.com:9000/usr/share/nginx/html/%1/$1
</VirtualHost>
So this should allow me to create a folder in /usr/local/apache2/htdocs
and then when I go to that web server using <folder>.domain.com
it will just know to send me to that subfolder as the root.
However, this doesn’t work with ProxyPassMatch
because %1
does not get expanded correctly. Using %{SERVER_NAME}
technically could work, but that produces a different set of limitations like not being able to easily select the first part of the URL (i.e for folder.domain.com
I want the variable to resolve to folder
only so the path it looks in is /usr/local/apache2/htdocs/folder
instead of /usr/local/apache2/htdocs/folder.domain.com
.
How can I have dynamic VirtualHosting and ProxyPassMatching? I’d really rather not use mod_rewrite
because I think that won’t actually solve the issue for ProxyPassMatching and it’s an ugly solution compared to what should work (%1/$1
).
For example, this works:
But requires Rewrite usage.