I use apache as reverse proxy, is there any way to ProxyPass only if my subdomain match a specific string, something like :
<VirtualHost *:80>
ServerAlias *.example.com
<If "%{HTTP_HOST} -strmatch 'hello*.example.com'">
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.22/"
ProxyPassReverse "/" "http://192.168.1.22/"
</If>
</VirtualHost>
Its not possible to use ProxyPass inside “If”, is there any work arround to achieve the same goal ?
thanks !
2
Answers
I think you can use either Regex or RewriteCond if it’s possible and I’ll explain my solution for this problem :
Since you want the same exact string to match, you can exclude everything except that string you’re looking for, I’ve written for you a RewriteCond if it’s usable :
This code should work, if it doesn’t I’ll search a regex condition to make the same pattern with different method, excluding every subdomain except the one that matches with hello.example.com
I have also this other code
I would try it with mod_rewrite and the Proxy directive.