Setup Apache as a proxy server for Exchange

Home Page | Comments | Articles | Faq | Documents | Search | Archive | Tales from the Machine Room | Contribute | Set language to:en it | Login/Register

Your mission is to install an Exchange server in our LAN with the Web interface (also called Outlook Web Access) available on Internet trought https without setting up Exchange on the DMZ and without ISA server that is way too expensive.

Now, it doesn't look really impossible... so far...

What I discovered almost immediately is that that crappy Exchange always return to the web client absolute URL, something like http://ip.address.of.server/... and this is a big no-no for using a proxy.

So, after a lot of screaming, cursing and RTFMing I figured it out...

First of all is necessary to have a clear picture of the server names involved in the game.

So let's put it like this: is Exchange (LAN) the server name isn't really important in this case. is the Apache Proxy (DMZ) and available from Internet with IP x.y.z.k

We have to decide the name that will be used to access the Web interface from the internet, let's make it something like And keep this in mind because is the cornerstone of the whole thing.

Be sure also to have registered a DNS entry that will resolve the FQDN into the correct IP address. So doing a ping I should receive an answer from x.y.z.k.

NOTE: Name and IP addresses are (of course) fictional, don't use these, use your real IPs and names.

To setup Exchange for https you have to create a certificate or a request for a certificate and have the real certificate signed by some external CA. Do whatever you want about it, but be really sure to use the FQDN of the web access for the certificate or request.

So, request the certificate for and not for another name (like the machine name or the IP address).

Exchange will use the name in the certificate in every html page and as a referral, so if you get the wrong name/url is a mess.

When exchange is configured and working, try accessing the web interface from your internal network, so point your browser to and you should see the webmail login page.

Note the Address bar of the browser, should display something like

If it display something else, you have a problem.

To end the test, go on a different machine, and edit the file c:\winnt\system32\drivers\etc\hosts and add a line like
And then try to access in the local browser, you should see again the webmail login page.

Please DON'T ask me how to create a certificate for Exchange, just read the documentation on the Microsoft support site for this.

You need to have both mod_ssl and mod_proxy compiled into apache, as a module or static, it doesn't really matter.

Maybe you need to recompile Apache to have it working. See the documentation on or

Again, you'll have to create or require a certificate, and again you have to use the FQDN name of as common name of the certificate.

To configure apache is a breeze: edit httpd.conf, locate the SSL part and add the following lines for the proxy:

ServerName ProxyPass / ProxyPassReverse /

Once done this there is only one single detail missing: to add in /etc/hosts a reference to so he get resolved in the Lan address of the machine:

Start Apache with SSL support and check that from the proxy a ping to is solved in, be sure that the firewall allow https to pass to the proxy.

Now, if you've done everything correctly, you should be able to point a browser from anywhere in the world to and see the login page of Exchange in the full glory.

After some discussion with Scott Lowe on alt.apache.configuratio, Scott came out with this alternate solution that doesn't require https on Exchange:

    RequestHeader set Front-End-Https "On"
    ProxyRequests Off
    ProxyPreserveHost On
    SSLEngine On
    ...more SSL directives...




As you can see, Scott used 3 'location' directives to proxy only the 3 directories used by Exchange. On the Exchange server is necessary to add a line to the HOSTS file to link '' to the same IP of Exchange, forcing Exchange to use that as his FQDN.

The RequestHeader directive is the key of the problem, this instruct Exchange to use https instead of http in his pages. The ProxyPreserveHost allow us to use the FQDN of the proxy where the one of the Exchange server is.

Note: I haven't tested this solution myself, so if it doesn't work for you complain to Scott and not with me.

Gabriele di Geronimo send this information:

This is a problem I encountered only using Internet Explorer, after getting the login screen I get a "404" page or an "Internal Server Error".
After fiddling in the proxy and in the configuration of Exchange it seems that the problem is due to the 'Use Windows Authentication' option in IIS on the server side. Turning it off everything works as expected.
Since Apache doesn't return any problem nor does IIS, I've no idea really where this problem is caming from, I've found this by trial and error.

Comments are added when and more important if I have the time to review them and after removing Spam, Crap, Phishing and the like. So don't hold your breath. And if your comment doesn't appear, is probably becuase it wasn't worth it.

No messages this document does not accept new posts

Previous Next

Davide Bianchi, works as Unix/Linux administrator for an hosting provider in The Netherlands.

Do you want to contribute? read how.  

This site is made by me with blood, sweat and gunpowder, if you want to republish or redistribute any part of it, please drop me (or the author of the article if is not me) a mail.

This site was composed with VIM, now is composed with VIM and the (in)famous CMS FdT.

This site isn't optimized for vision with any specific browser, nor it requires special fonts or resolution.
You're free to see it as you wish.

Web Interoperability Pleadge Support This Project
Powered By Gojira