Previous Next

Thread: Accessing IIS via hostname specified in local hosts file

Last post 02-28-2008 11:27 AM by philruelle. 7 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (8 items)

Sort Posts:

  • 02-27-2008, 12:24 PM

    Accessing IIS via hostname specified in local hosts file

    Hi,

    If I have a local website with Integrated Windows Authentication I can access it fine via http://localhost and http://127.0.0.1. However if I put an entry into the machine's hosts file e.g.

    127.0.0.1    mysite

    http://mysite does not work. When hitting this website an entry is created in the security log on the machine suggesting that it has logged in fine but each time the browser comes back with a challenge-response and after 3 times I get a 401.

    Can anyone shed any light on this? It is confusing behaviour or have I misunderstood? I am reliably informed that this sort of thing was possible in IIS 5. I am using Windows Server 2003/IIS 6.

    Thanks in advance,

    Phil

  • 02-27-2008, 12:35 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Lawrenceville, NJ
    • Posts 4,038
    • IIS MVPs

    Re: Accessing IIS via hostname specified in local hosts file

    This could at least in part be an IE config issue as it does not recognize that name as part of your trusted intranet.
    http://support.microsoft.com/kb/258063

    What sub-status code are you getting (check the IIS log file) - 401.1 or 401.3?  What authentication modes are enabled?

  • 02-27-2008, 5:13 PM In reply to

    Re: Accessing IIS via hostname specified in local hosts file

    tomkmvp:

    This could at least in part be an IE config issue as it does not recognize that name as part of your trusted intranet.
    http://support.microsoft.com/kb/258063

     

    Thanks. I'll check this out back at the office tomorrow. As a matter of note we first discovered this issue when an ASP.Net website was making a HttpWebRequest back to it's own website via a clustered address and in order to force the request to be handled on the same machine we put the clustered address name into the web server's Hosts file as 127.0.0.1.

    tomkmvp:

    What sub-status code are you getting (check the IIS log file) - 401.1 or 401.3?  What authentication modes are enabled?

     

    The status code is 401.1.

    Anonymous access is turned off and the only authentication method turned on is Windows Integrated authentication.

  • 02-27-2008, 6:16 PM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Lawrenceville, NJ
    • Posts 4,038
    • IIS MVPs

    Re: Accessing IIS via hostname specified in local hosts file

    A 401.1 indicates that IIS is unable to authenticate the user.  Are you logged on with a local or domain account?  Is this machine a member of a Windows Domain?

  • 02-28-2008, 6:23 AM In reply to

    Re: Accessing IIS via hostname specified in local hosts file

    When I hit the website via http://localhost, http://127.0.0.1 or http://mySite IE throws up the login box. When hitting the first 2 addresses it accepts the credentials I enter. When I enter the same credentials for http://mySite (which only exists as an entry in the hosts file) it rejects them and after 3 attempts I get the 401.1 page.

    The box is a domain member and the login details I enter are for a user in that same domain.

  • 02-28-2008, 9:48 AM In reply to

    Re: Accessing IIS via hostname specified in local hosts file

    philruelle:
    127.0.0.1    mysite

    Don't ever set your host name to the loopback address 127.0.0.1.  Set your host name to the physical IP address of the system.

    Jeff

    Look for Wrox's new book Professional IIS 7 in your local bookstore, or order now at Amazon.com
  • 02-28-2008, 10:43 AM In reply to

    • tomkmvp
    • Top 10 Contributor
    • Joined on 03-20-2003, 10:27 AM
    • Lawrenceville, NJ
    • Posts 4,038
    • IIS MVPs

    Re: Accessing IIS via hostname specified in local hosts file

  • 02-28-2008, 11:27 AM In reply to

    Re: Accessing IIS via hostname specified in local hosts file

    Well I didn't know that! Thanks. Can you explain (or point me in the direction of) the reason behind that?

    Anyhoo the problem is still exhibited even when I use the physical IP. The situation is made more annoying by the fact that if I put the address of another server in the same domain into my hosts file along with a "made-up" name, e.g.:

    10.100.1.2 mySite

    I can then type http://mySite into the browser, enter the credentials and it works fine. The problem only occurs if I try to map the IP of the local machine to a "made-up" name. It makes me think that as part of the security features of IIS 6.0 MS added something that prevents this although I'm stumped as to why....

Page 1 of 1 (8 items)
Page view counter