Outlook Web Access (OWA) is the web-based interface for accessing e-mail and other resources handled by Microsoft Exchange. Unfortunately, OWA’s popularity also makes it the target of numerous worms and security exploits. As a result, many organizations seek to deploy OWA behind a reverse proxy that can help shield OWA from web-based attacks and exploits. In this posting, I’m going to share information to help build a reverse proxy using Apache 2.0.
Here’s a skeleton of an httpd.conf file to support Apache as a reverse proxy in front of OWA:
NameVirtualHost 1.2.3.4:80 NameVirtualHost 1.2.3.4:443 ProxyRequests Off <VirtualHost 1.2.3.4:443> ServerAdmin webmaster@domain.com ServerName webmail.domain.com DocumentRoot /var/www/webmail RequestHeader set Front-End-Https “On†ProxyRequests Off ProxyPreserveHost On SSLEngine On SSLCertificateFile conf/webmail-ssl-cert.pem <Location /exchange> ProxyPass http://mail.domain.com/exchange ProxyPassReverse http://mail.domain.com/exchange SSLRequireSSL </Location> <Location /exchweb> ProxyPass http://mail.domain.com/exchweb ProxyPassReverse http://mail.domain.com/exchweb SSLRequireSSL </Location> <Location /public> ProxyPass http://mail.domain.com/public ProxyPassReverse http://mail.domain.com/public SSLRequireSSL </Location> </VirtualHost>
The key portions of this configuration are described below, along with some supporting information.
- NameVirtualHost: The NameVirtualHost directive enables Apache to use name-based virtual hosts on the specified IP addresses and ports. The parameter to the NameVirtualHost directive must match one of the VirtualHost definitions, as shown in the sample configuration, or else the content will be served from the default virtual host (the first virtual host listed in the configuration). Note that if the Apache reverse proxy will not be using name-based virtual hosts (instead using IP address-based virtual hosts or running only a single server instance), then this directive is not required.
- RequestHeader: This directive instructs Apache to add a header “Front-End-Https: On†to requests sent to the internal OWA server. This header is proprietary to OWA and forces OWA to build URLs using “https://†references instead of ordinary “http://†references. This directive is required in order to terminate the SSL tunnel at the reverse proxy and use clear-text HTTP between the reverse proxy and the internal OWA server. This directive requires the mod_headers module.
- ProxyPreserveHost: This directive configures Apache to pass the original host header, supplied by the client, to the server to which the request is being proxied. (This is instead of the host name supplied in the ProxyPass directive.) Again, this facilitates the construction of URLs with the correct hostname when accessing resources inside OWA.
- SSLCertificateFile: Apache expects the web server’s SSL certificate to be in PEM format. If the certificate’s key is encrypted, Apache will prompt upon startup for the passphrase to the key (this prevents any form of automated startup). It is considered a security best practice to keep the key in a separate file (using the SSLCertificateKeyFile directive) in encrypted form and supply the password upon the startup of Apache.
With this configuration in place, the following benefits are realized:
- Name-based virtual hosts are supported. This allows other URLs to also be proxied through this same reverse proxy server.
- SSL encryption is offloaded from the Exchange server to the reverse proxy server. Traffic from the reverse proxy server itself to the Exchange server is standard, unencrypted HTTP.
- When used in conjunction with mod_security (another Apache module), OWA is protected against a very significant majority of all web-based attacks.
Using Apache to serve as a reverse proxy for OWA is a cost-effective way to add another layer of security to an Exchange-based messaging infrastructure.


6 comments
Thursday, January 18, 2007 at 6:52 pm
Pingback from djitz.com » Blog Archive » Setup Reverse Proxy with Apache for Lotus Notes Webmail
Friday, August 18, 2006 at 5:39 pm
Vladimir Jirasek
Hello,
I have been trying to protect OWA with Apache2 reverse proxy but I am receiving the error message: client denied by server configuration: proxy:http://xxxxxxxxx/Exchange/.
Even when I changed the confirguration slightly according to your blog it did not work. I have basic authentication enable on OWA server and from within the internal network the OWA works fine. I simply supply my credentials and log in.
The only difference in the config is that I use client certificates to authenticate to reverse proxy:
ProxyPass http://lawin-srv01/Exchange/
ProxyPassReverse http://lawin-srv01/Exchange/
SetEnv force-proxy-request-1.0 1
SetEnvIf User-Agent “.*MSIE.*” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
SetEnv proxy-nokeepalive 1
SSLVerifyClient optional
SSLVerifyDepth 1
SSLOptions +OptRenegotiate
# +StdEnvVars +ExportCertData
SSLRequire %{SSL_CLIENT_S_DN_O} eq “company name”
#Require 128 and more bits
SSLRequire %{SSL_CIPHER_USEKEYSIZE} >= 128
But even when I remove lines !SSLRequire %{SSL_CLIENT_S_DN_O} eq “company name”! it does not work.
Will continue looking for the solution.
Vladimir
Saturday, August 19, 2006 at 1:02 am
slowe
Generally, the ProxyPass and ProxyPassReverse directives will have the externally accessible DNS name listed. It looks like you are using your inernal name there…is that accurate? If so, be sure to specify the externally accessible name, and make sure that name can be properly resolved from the proxy system itself as well.
Hope this helps!
Sunday, August 20, 2006 at 7:50 am
Vladimir Jirasek
Hi,
the hostname lawin-srv01 is reasolvable and actually when I do lynx http://lawin-srv01/Exchange and authenticate using basic authentication I can access my inbox. Actually I changed the config to proxy to IP address specifically - nothing. DNS resolves the correct IP address of the internal server.
Also the access with certificate works fine for files on the local system (proxy server itself). The fact is the proxy server does not even send any packets towards internal OWA server. Simply denies the request! Even when I direct it to proxy to enother Linux based server on the same LAN it does not work….
Thanks for help…
Vladimir
Sunday, August 20, 2006 at 6:22 pm
Vladimir Jirasek
Hi,
I have got it working. All it needed was:
Allof from all
in Localtion section
Cheers
Vladimir
Sunday, August 20, 2006 at 9:47 pm
slowe
Vladimir,
Glad you finally got it to work. Thanks for getting back and letting us know!