ubuntu - 没有 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 进入服务器时,自动重载正在工作。
- 我已经添加
config.vm.network "forwarded_port", guest: 8080, host: 8080, host_ip: "127.0.0.1"
到 Vagrantfile ,它将右侧的第一个条目添加到Network-Settings。这似乎没有什么区别,因为我仍然需要有一个活动的 ssh 隧道。 curl -v 'http://localhost:8080'
我可以从返回的 guest-vm 卷曲页面HTTP/1.1 200 OK
- 当我通过
curl -v 'http://localhost:8080'
没有 ssh 隧道从主机卷曲页面时得到什么
* 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
- 当我使用活动的 ssh 隧道从主机卷曲时:
$ 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 隧道的情况下让这个功能工作?
解决方案
推荐阅读
- python - App.route 在 Flask 中不适用于一种方法
- wordpress - Divi Visual Builder 越野车
- r - 将基因位置映射到染色体坐标
- html - 设置内联 SVG 的填充颜色
- solr - org.apache.solr.common.SolrException:搜索处理程序的错误内容类型:application/xml;字符集=UTF-8
- html - HTML 只是一个连续的图像
- c# - 没有为此 DbContext 配置数据库提供程序。尝试更新数据库时出错
- javascript - 如何让一个按钮单击 React 中不同组件的另一个按钮
- python - Pandas - 如何对格式化为字符串的周数和年份数进行排序?
- excel - 编译错误 - 更新枢轴时预期的数组