The other day, I was asked by a customer how one is able to run ColdFusion with IIS and Apache on the same machine with both Webserver listening on port 80. Since this customer has downloaded our free Digital Asset Management solution, I knew his question was aimed at the Oracle HTTP Server (Apache 1.3) and that solving this could also help our own website and customers behind a firewall which would not allow traffic on port 7777 (the default port installation by Oracle HTTP).
After some thinking I came to the conclusion that this will only be possible with two IP addresses assigned to your network adapter. Thus first we need to assign the new IP to the network adapter.
If that is done we now have to tell IIS and Apache to only listen to the specified IP address. The big problem with this approach is that IIS has a featured called “Socket Pooling” that claims all ports for all loaded IP addresses, even if not configured in IIS!!!. Actually this has struck me for quite some time and it took quite some searching and reading to find this out. Fortunately there is a way to configure IIS to only listen to the IP we want.
Configure IIS to listen to only one IP address
1. First of all grab yourself the “httpdcfg.exe” utility which is within the .cab file within the support folder of the Windows Server 2003. With the latest releases you will find the folder on CD 2. To make it even easier I make it available here.
2. Now go into the command prompt and stop IIS with “net stop http /y”
3. Now tell IIS to listen to the IP you want with “httpcfg set iplisten -i 192.168.1.100″
4. Make sure that IIS has only your IP configured to listen for with “httpcfg query iplisten”
5. Restart IIS with “net start w3svc” (Changes are done but you might not see them already).
Configure Apache to listen to only one IP address
Next we need to tell Apache to only listen to the other IP address. Fortunately this takes only some small part of configuring.
1. Open up your “httpd.conf” file.
2. Search the line where it says “listen 7777″ (or your port you want to change).
3. Change this to read: Listen 80 Listen 192.168.1.101:80 If you have virtual host containers setup to listen to a IP address you will need to change those values as well, of course.
4. Save.
VERY IMPORTANT: If you have done the above you must restart your machine. Doing otherwise with just restarting IIS and Apache will not reflect the changes correctly. If you see it working we still recommend restarting your server (hey, after all it is Windows
)
Voila, after you have restarted your machine you should be able to access both IP’s one being served by IIS and the other by Apache.
This setup has been tested and known to work with Windows Server 2003 and IIS 6.x and Apache 1.3.x. Also this setup would add some security to your database since you could have a public IP address for, as an example, your IIS and have an internal IP address to your Oracle database over Apache. Your requests to the database would then go to the internal IP. Within Coldfusion your data source would then point to the internal IP. This would be a “secure” setup for your web applications which would only allow access to the database trough your web application.
Sphere: Related ContentIf you enjoyed this post, make sure you subscribe to the RSS feed!
or
you can put Apache as the front server because IIS just suck
and use a reverse proxy on IIS listening on port 8080 or any other
http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
I think this with the proxy server only works on 2.0 no? In my post I wrote about 1.3, but maybe it works as well.
One thing I constantly notice is that some people always have to post that "IIS really sucks". Despite of not liking Microsoft, is there a concept of proof to backup your saying? Is IIS really that bad, since there are still thousands of websites running on IIS, which means about 31% (according to NetCraft) out of 101,435,253 sites.
In our work we have dealt with Apache and IIS and we don’t really see that one is better then the other. I think it is more based on what your personal choice is, no?
IIS suck because as a web server it can not do as much as Apache
and if I say that it’s not because I don’t like microsoft (I do run Apache on windows server 2003)
it’s because I have to use IIS for some cases (as .NET webapp)
but for too many simple things IIS can not compare to Apache
Apache do solve your server problems , IIS got in the way
some examples:
- try to have clean resty URLs with IIS
- try to do some mass virtual hosting
- try to do webdav/FTP services
etc…
all these are simply solved in Apache, not in IIS
yep even with commercial ISAPI filters and/or COM objects
so please spare me the "oh you just don’t like microsoft products"
no, IIS do suck compared to Apache
setting up a reverse proxy in Apache take 3 phracking line of config
and it work great
Thank you for your answer. You know, sometimes you have to ask who you are talking too
Care to post the "3 lines of code" so we can all benefit? Thank you.
no problem
ok so a basic config (tested with Apache 2 and IIS 6)
IIS 6
http://www.domain.com listening on 8080
Apache2
<VirtualHost *:80>
ServerName http://www.domain.com
ProxyPreserveHost On
ProxyPass / http://www.domain.com:8080
ProxyPassReverse / http://www.domain.com:8080
</VirtualHost>
the advantage of doing that is you need only one IP
and you can have virutal hosts in Apache and in IIS
and if you study a little the doc about mod_proxy and mod_rewrite
you realize you can also do that at the URL level
for example having Apache handdle *.html files
and the reverse proxy redirecting to IIS for *.aspx pages
forthe same host
ProxyPass /something http://www.domain.com:8080/aspwebapp
http://www.domain.com/page.html -> Apache
http://www.domain.com/something/page.aspx -> IIS
you can off course have the 2 servers on 2 different IP and 2 different physical server
or all on 1 server, after is just some pache conf tweaking
depends on your needs, load balacing etc.