Jun 16
Using Apache reverse proxying with IIS
Posted by James Netherton | Saturday 16 June 2007 12:07 PM | In Apache
Apache and IIS can live quite happily together on the same server, handling requests when they are on configured on different ports. What happens if you want to run both solutions in the same environment on port 80?
To start with IIS will capture all traffic on the port that its configured to run off of, in which case Apache will never receive any traffic.
One solution could be to run websites within IIS off a different port and set Apache to listen on port 80. You could then use a technique called reverse proxying to pass requests for specific URLs, domains and paths to IIS, allowing it to serve up content as if it were running off port 80.
Here's an example of how you might configure something like this using Apache. The usual caveats on ensuring you backup your Apache configuration file apply.
1. Add the website IP's that you want Apache to listen out for under the listen directive of the Apache config file.
2. Ensure that the following Apache modules are loaded:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
3. Configure the IIS websites you want to use for reverse proxying, so that they run off a port other than port 80 (8080 for example).
4. Back to the Apache config file, enable virtual hosts.
NameVirtualHost *:80
5. Configure virtual hosts for each site where you want to direct requests to IIS.
<VirtualHost *:80>
ServerName www.domain.com
RewriteEngine On
ProxyVia Block
ProxyPreserveHost On
RewriteRule ^/(.*)$ http://hostname:8080/$1 [P,L]
</VirtualHost>
What's happening above is that any requests received under www.domain.com are rewritten to another domain name under port 8080.
6. Restart Apache and IIS.
That should be all there is to the process. Browse to one of the domains that you have configured for reverse proxying to see whether everything has worked. You'll know for sure that its working if you view the Apache access_log file and see that it is logging requests for sites that are running off IIS.
0 Comments
[Post comment]