【发布时间】:2016-12-17 05:15:19
【问题描述】:
我有一个节点应用程序在端口 5000 上基于 Centos 7 的 VM 中运行。当我在 VM 中打开浏览器时,我可以访问 http://localhost:5000。我也在 Virtualbox 中转发端口 5000/TCP。直到最近,我才能够访问主机上的相同 URL。我能够通过 SSH 连接到机器,所以我可以假设客人添加不是罪魁祸首。
当我从主机卷曲时,我得到以下输出:
curl -v http://localhost:5000
* Rebuilt URL to: http://localhost:5000/
* Trying ::1...
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.46.0
> Accept: */*
>
* Recv failure: Connection was reset
* Closing connection 0
curl: (56) Recv failure: Connection was reset
来自客人的卷曲成功:
curl -v localhost:5000
* About to connect() to localhost port 5000 (#0)
* Trying ::1...
* Connected to localhost (::1) port 5000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:5000
> Accept: */*
>
< HTTP/1.1 200 OK
< Cache-Control: no-cache="Set-Cookie, Set-Cookie2"
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
< X-XSS-Protection: 1; mode=block
< Content-Type: text/html; charset=utf-8
< Content-Length: 13545
< ETag: W/"34e9-XRkZVDhS9RNYciepFhTD7A"
< Vary: Accept-Encoding
< Date: Wed, 10 Aug 2016 17:11:16 GMT
< Connection: keep-alive
<
<!DOCTYPE html>...
端口转发设置如下所示 - 只有 SSH 有效,尽管我已尝试向我要访问的服务添加和删除主机 IP。
如何进一步解决此问题?
这可能是最新版本的 virtualbox 的问题吗?
【问题讨论】:
-
您的 VirtualBox 端口转发设置是什么样的?当您发出 curl 请求时,这是在 VM 上还是在您的主机上?对面(VM/主机)是什么样的?
-
感谢 Lucas,我已经更新了问题,以便在访客和主机上都显示 curl。
标签: node.js virtualbox centos7