尝试访问我的主机文件中设置的本地 IP 地址时出现 ERR_CONNECTION_REFUSED

问题描述

设置:

MACHINE_A 正在运行多个 docker 容器,包括一个 dockerized ember 服务器和一个 dockerized Nginx 服务器。机器的本地IP地址是192.168.50.46。其主机文件修改包括

127.0.0.1   localhost
127.0.0.1   sub.domain.localhost

Nginx 服务器代理从 sub.domain.localhost 到我们的 dockerized ember 服务器的请求:

location = / {
  proxy_pass http://host.docker.internal:4200;
  error_page 404 500 502 503 504 =200 /index.html;
}

MACHINE_B 在同一网络上。其主机文件修改包括

192.168.50.46   sub.domain.localhost

什么有效:

在 MACHINE_A 上,我可以在 chrome 的网址栏中输入 127.0.0.1:4200localhost:4200,它将运行我的应用程序。我也可以输入 sub.domain.localhost 就可以了。

在 MACHINE_B 上,我可以在 URL 栏中输入 192.168.50.46:4200,它会运行应用程序。

什么不起作用:

在 MACHINE_B 上,如果我输入 sub.domain.localhost,我会收到 ERR_CONNECTION_REFUSED 错误

问题:

为什么?我们能做些什么吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)