首页 > 解决方案 > 没有 ssh-tunnel 的 vagrant-vm 的 Hotmodule 自动重新加载 chrome

问题描述

我有一个在 Oracle VM Virtualbox 中运行并安装了 webpack 的 Vagrant VM。

当我将 Webpack-Node 服务器公开到127.0.0.1:8080然后 ssh-tunnel 到ssh -L 8080:localhost:8080 vagrant@192.168.33.10. 之后,我可以使用浏览器通过localhost:8080. 当我将它暴露给我时,0.0.0.0:8080我可以通过192.169.33.10:8080没有 ssh-tunnel 的方式访问服务器,但浏览器不会自动重新加载更改,因为它们无法再进行通信?当我现在 ssh-tunnel 进入服务器时,自动重载正在工作。

 * Rebuilt URL to: http://localhost:8080/
 * timeout on name lookup is not supported
 *   Trying ::1...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 127.0.0.1...
 * Connected to localhost (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.49.1
> Accept: */*
>
 * Recv failure: Connection was aborted
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
 * Closing connection 0
curl: (56) Recv failure: Connection was aborted
$ curl -v 'http://localhost:8080'
* Rebuilt URL to: http://localhost:8080/
* timeout on name lookup is not supported
*   Trying ::1...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to localhost (::1) port 8080 (#0)
> GET / HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.49.1
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Accept-Ranges: bytes
< Content-Type: text/html; charset=UTF-8
< Content-Length: 974
< ETag: W/"3ce-MASXCzkp0dBO+UKSABDYEzPzueg"
< Date: Mon, 15 Apr 2019 13:21:35 GMT
< Connection: keep-alive
<
{ [974 bytes data]
100   974  100   974    0     0  60875      0 --:--:-- --:--:-- --:--:--  951k<!DOCTYPE html>
<html>
<head>

....

由于我对网络和这类事情知之甚少,所以这个问题可能看起来很愚蠢,但是否有可能在没有活动 ssh 隧道的情况下让这个功能工作?

标签: ubuntuwebpackvagrantvirtualboxhot-module-replacement

解决方案


推荐阅读