I have a development machine setup with IIS 6. I have 3 websites configured on different IP addresses:
Default (All Unassigned) WS1 (192.168.1.250) WS2 (192.168.1.249)
I was wondering how IIS determines which site to hit when I specify localhost in the URL? Is this configurable? If so, how do I go about doing this?
When IIS responds to an HTTP request is uses 3 pieces of information to figure out what web site it should use to build the response.
www.foo.com secure.foo.com server1.foo.com subdomain.foo.com server2.subdomain.foo.com
, etc.Assumptions based on your question:
1 - Your machine has 3 ip addresses assigned:
2 - You have a 3rd ip address assigned to your machine that is the original IP address. (This may or may not be the case, I'm assuming it to be so since that's what most folks do when the assign IP's to web sites).
3 - The default web site in IIS has the IP address setting of: (All Unassigned)
.
4 - You have not specified any host headers or ports in your IIS config.
So, when running a browser on your machine you type: http://localhost
(no port number), what does IIS do?
Per previous replies the browser converts localhost to 127.0.0.1 as the IP address and constructs an HTTP request for that IP address. The host header will be localhost
.
In this scenario IIS will see that both WS1 and WS2 do not have matching ip addresses and so the default site will be used to process the request.
If you wish to have WS1 or WS2 respond to the request, disable the default site and change the IP address setting to (All Unassigned)
for either WS1 or WS2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With