For a while I have been running two different server environments on my Windows 7 OS. IIS runs on 127.0.0.1 and I have a Vagrant VM that uses 192.168.33.10. My hosts file looks something like:
- vagrantsite1.localhost 192.168.33.10
- vagrantsite2.localhost 192.168.33.10
- iissite1.localhost 127.0.0.1
- iissite2.localhost 127.0.0.1
Up until a week or so back, this setup worked perfectly fine, however something has changed recently with my Chrome browser. Now all of a sudden in Chrome when I access vagrantsite1.localhost it is referencing the IIS 127.0.0.1 IP address instead of 192.168.33.10. I checked this using chrome://net-internals/#dns and even cleared the host cache, which did not seem to resolve anything.
After some research I have found if I add localhost 192.168.33.10 to my hosts file, the vagrant sites work, however now my IIS sites try to access this IP instead of 127.0.0.1. It seems that Chrome does not let me use a different IP for somesite.localhost from localhost entry. This is not a problem in IE and Firefox, and up until recently it was not a problem in Chrome.
I was wondering if anyone else has this problem or a potential solution (rather than manually setting localhost IP each time I want to switch servers)? I realize I can use a different port number for one of the servers as a solution, however since everything works fine in IE and Firefox, and until recently worked fine in Chrome, I would like to know the cause.
This is a "feature" that was just added to chrome, all localhost domains will always resolve to loopback.
See the following links for more information:
- https://code.google.com/p/chromium/issues/detail?id=455825
- https://codereview.chromium.org/938093003
One workaround is to change your entries to not end in localhost, something like "vagrantsite1.local 192.168.33.10" instead should work.
来源:https://stackoverflow.com/questions/30579720/chrome-now-treating-ip-address-of-localhost-same-as-somesite-localhost