Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I have found a solution to this problem.

What I am doing now is this. I have set up every web app as:

  • A web site on IIS, with its own binding to a specific host name such as "intranet" in my original example.
  • A web application under the Default Web Site, which keeps the default catch-all binding with no host name.

For example, the Intranet web app appears as a site on IIS named "Intranet" with a binding to the host name "intranet", so that people accessing the server as http://intranet/ will be directed there; and it also appears as a webb app named "Intranet" under the server's default web site, so that users accessing the server as http://xxx.xxx.xxx.xxx/intranet will be sent there as well. They are two different ways to reach the same physical folder and the same content, and it works flawlessly.

Thanks to all who have helped!

share|improve this answer

In short: don't use the second method.

In the Site Bindings for the site, just specify both intranet and yourpublicname.yourdomain.com as the host headers.

Then, assuming it's internet accessible, the same site will be served for both, with different bindings.

Translating the path to and from a site is tricky; better to keep the same site layout and just add a binding?

(Why not do this?)

share|improve this answer
    
I can't do this because our web server does not have a publicly-visible name. In other words, its name is on a private DNS server that works inside the corporate network, but there is no public name for it. The only way I can think of to access it from outside is by IP address, and hence the problem. –  CesarGon Aug 9 '11 at 10:15
    
You could simply register a name with an external DNS provider, which would fix this problem. Your solution of allowing it to "fall through" to the default binding also works. –  TristanK Aug 14 '11 at 1:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.