我有一个运行Webpack的Oracle VM Virtualbox中运行的Vagrant VM。
当我将Webpack-Node Server公开到127.0.0.1:8080
,然后将ssh-tunnel公开到ssh -L 8080:localhost:8080 vagrant@192.168.33.10
时,浏览器的热模块自动重载功能正在工作。
之后,我可以使用浏览器通过localhost:8080
连接到NodeServer。当我将其公开给0.0.0.0:8080
时,可以通过192.169.33.10:8080
到达服务器,而无需使用ssh-tunnel,但是浏览器不会自动重新加载更改,因为它们不再通信了?现在,当我通过ssh-tunnel进入服务器时,自动重装正在工作。
config.vm.network "forwarded_port", guest: 8080, host:
8080, host_ip: "127.0.0.1"
添加到Vagrantfile中,该文件将右侧的第一个条目添加到Network-Settings中。似乎没有什么不同,因为仍然需要我有一个活动的ssh-tunnel。curl -v 'http://localhost:8080'
中卷曲页面,该虚拟机返回HTTP/1.1 200 OK
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* 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隧道,是否有可能使此功能正常工作?