Okay, I think this is a fairly simple task, but I'm having a little trouble testing reliably and working out what I've done wrong. I tried to follow the Apache mod_rewrite documentation, but it doesn't appear to be working the way I expected.
I have an Apache server running as a reverse proxy in front of an Exchange CAS for public OWA access, and we want to intercept ActiveSync traffic (simple pattern match) and redirect it to an AirWatch Secure Email Gateway (SEG) URL. All other (i.e. web browser OWA) traffic should be sent along to the CAS as usual.
So what we started with is something like this, and this works perfectly for OWA access, but doesn't do the ActiveSync-to-SEG redirect:
<VirtualHost *:443>
ServerName webmail.company.com:443
RewriteEngine on
RewriteRule ^/$ https://webmail.company.com/exchange [R,L]
<Location />
Order allow,deny
Allow from all
# This is the CAS's internal IP
ProxyPass https://10.100.10.209/
ProxyPassReverse https://10.100.10.209/
</Location>
</VirtualHost>
So I added this line (the one in the middle) in an attempt to rewrite URLs that begin with "/Microsoft-Server-Activesync/[whatever]" into "https://seg.company.com/Microsoft-Server-Activesync/[whatever]":
<VirtualHost *:443>
...
RewriteEngine on
RewriteRule ^/Microsoft-Server-Activesync?(.+)$ https://seg.company.com/Microsoft-Server-Activesync?$1 [R]
RewriteRule ^/$ https://webmail.company.com/exchange [R,L]
...
</VirtualHost>
When I made this change (in test, of course), the traffic I'm sending to it from a mobile device does not appear to be getting redirected. Instead the ActiveSync traffic just flows along to the Exchange CAS as usual like the rule is not being triggered.
So, two questions:
- Am I doing something obvious wrong with the RewriteRule I added?, and
- How can I troubleshoot this a little more intelligently than, "Hit ActiveSync URL in a browser, check web server logs to find out where it went"?
Thanks in advance!
Regards, Jon Heese