This post will help you run IIS and Apache Web Server together even if you can't manage to add multiple IP addresses (may be because your ISP refuses to assign you so).
It is fairly simple to use Apache Web Server as a proxy to reach IIS. Your sites users will make direct requests to Apache Web Server and when we have finally configured our Apache Web Server, all requests will be proxyed to IIS. You can also configure multiple domains (blogged earlier) in to only proxy requests for particular virtual hosts (particular websites).
Here is what you need to do:
- Configure your IIS website to listen to port number 8080 or any other number not in use in your system. So if your website URL was http://www.my-site.com, it will now be http://www.my-site.com:8080/
- Start Apache Web Server and make sure Apache can listen to port 80. If Apache web server FAILS, you can use bind settings specified in the earlier post that includes info on changing bind settings of IIS. You may have to restart your server.
- Make sure you can start both web server and hit both IIS and Apache from local machine using different ports.
- Now open Apache configuration file, httpd.conf. This file is located inside the installation directory under /conf folder. Usually it is placed under: C:\Program Files\Apache Software Foundation\Apache2.2\conf
- Scroll to the bottom of this file and add the following text to tell Apache Web Server to load the two following modules and enable proxy sites capability:
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so ProxyRequests Off #keep proxy to OFF or your server will act as a forward proxy
- At the bottom, add a new virtual host in the following way: (read howto if you are not sure about vhosts)
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.my-site.com ServerAlias *.my-site.com DefaultType text/html <Directory "C:\Inetpub\wwwroot"> Options Indexes FollowSymLinks AllowOverride none Order allow,deny Allow from all </Directory> # sends all requests made to port 80 to another port 8080 ProxyPass / http://www.my-site.com:8080/ #makes proper changes to server-side redirection header ProxyPassReverse / http://www.my-site.com:8080/ </VirtualHost>
- Restart Apache Web Server and bingo, you're done!
ProxyPass is the magic statement and the power of mod_proxy_http and mod_proxy means that you can run any other Application Server or Web Server behind your Apache Web Server and enjoy the benefits of multiple web servers.
This effectively means that you can now run ASP.net with Apache Web Server!
Note: Don't use this technique to create fake Yahoo or GMail sites inside a office network!