Chrome现在将localhost的IP地址与somesite.localhost相同 [英] Chrome now treating IP address of localhost same as somesite.localhost

查看:260
本文介绍了Chrome现在将localhost的IP地址与somesite.localhost相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在Windows 7 OS上运行两个不同的服务器环境. IIS在127.0.0.1上运行,我有一个使用192.168.33.10的Vagrant VM.我的主机文件看起来像:

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

直到一周左右,此设置都可以正常运行,但是最近我的Chrome浏览器发生了一些变化.现在,当我访问vagrantsite1.localhost时,突然在Chrome中引用了IIS 127.0.0.1 IP地址而不是192.168.33.10.我使用 chrome://net-internals/#dns 进行了检查,甚至清除了主机缓存,该主机缓存似乎无法解决任何问题.

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.

经过一些研究后,我发现如果将 localhost 192.168.33.10 添加到我的主机文件中,那么无所事事的站点可以工作,但是现在我的IIS站点尝试访问此IP而不是127.0.0.1. Chrome似乎不允许我为 localhost 条目中的 somesite.localhost 使用不同的IP.在IE和Firefox中这不是问题,直到最近,在Chrome中这都不是问题.

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.

我想知道是否还有其他人有此问题或潜在的解决方案(而不是每次要切换服务器时都手动设置本地主机IP)?我知道我可以为其中一台服务器使用不同的端口号作为解决方案,但是,由于在IE和Firefox中一切正常,直到最近在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.

推荐答案

这是刚刚添加到chrome的功能",所有localhost域都将始终解析为回送.

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

一种解决方法是将您的条目更改为不以localhost结尾,类似"vagrantsite1.local 192.168.33.10"之类的方法应该起作用.

One workaround is to change your entries to not end in localhost, something like "vagrantsite1.local 192.168.33.10" instead should work.

这篇关于Chrome现在将localhost的IP地址与somesite.localhost相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆