I am hosting several web apps on IIS 7.5 on Windows Server 2008 R2. The server has a single IP address and I am using host names to differentiate the bindings to each application. The server has different DNS alias matching the host names, so all works fine within the corporate network. For example:
- When I type http://intranet, "intranet" gets resolved by DNS to the server's IP and a request is made to IIS, which uses the binding with the "intranet" host name, which in turn maps to the Intranet web app.
The thing is, I also want users to be able to access the apps from outside the corporate network, by using the server's IP (which is public). This means that IIS should also recognise requests made in the form http://xxx.xxx.xxx.xxx/intranet as corresponding to the Intranet web app. The only way I have found to achieve this is to place the physical folders for all the web apps under the physical folder of the Default Web Site, and leave the default binding for this site. This means that:
- When I type http://xxx.xxx.xxx.xxx/intranet, a request is made to IIS, which uses the binding with no host name, which in turn maps to the Default Web Site, and within this web site it looks into the "intranet" physical folder.
Things should work fine in theory, but I stumbled against the following problem. Most of the web apps I am hosting are ASP.NET apps, and use web.config files. When I access one of these apps directly, through the first method (i.e. using a host name), things work OK. However, when I access it using the second method, IIS complains that some settings in the web.config are at the incorrect level. I know why this happens: the request to IIS is being made to a physical folder within a higher-level web app, rather to the web app I am intending to visit, because of the way I have set up the bindings.
My question is: since this configuration strategy breaks ASP.NET web.config behaviour (and probably other things as well), is there other alternatives that I should consider to allow for both name- and IP-based access? Thank you.
EDIT. I have found a solution to this problem now; please see my own answer below.