【发布时间】:2014-04-09 04:15:50
【问题描述】:
我的主机文件将127.0.0.1 映射到localhost。
$ curl -I 'localhost'
curl: (7) Failed to connect to localhost port 80: Connection refused
然后
$ curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.2.4
Date: Wed, 09 Apr 2014 04:20:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Tue, 23 Oct 2012 21:48:34 GMT
Connection: keep-alive
Accept-Ranges: bytes
在我的主机文件中,我有
127.0.0.1 localhost
curl 命令似乎无法识别/etc/hosts 中的条目。谁能解释一下原因?
更新:我还没有尝试过,但我发现你可以配置nginx to respond to ipv4 and ipv6
【问题讨论】:
-
你也有
::1 localhost吗? -
是的,我有
::1 localhost -
如果您有多个 localhost 行,在这种情况下可能会使用您不期望的行(即 ::1)