docker - 尝试访问我的主机文件中设置的本地 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 上,我可以输入127.0.0.1:4200
并localhost:4200
进入 chrome 上的 url 栏,它将运行我的应用程序。我也可以输入sub.domain.localhost
,它会工作。
在 MACHINE_B 上,我可以进入192.168.50.46:4200
url 栏,它将运行应用程序。
什么不起作用:
在 MACHINE_B 上,如果我输入,sub.domain.localhost
我会收到 ERR_CONNECTION_REFUSED 错误。
问题:
为什么?我们能做些什么吗?
解决方案
推荐阅读
- node.js - 使用 app.js (express) 运行 NestJS 应用程序
- node.js - 如何使用 AWS Lambda (nodeJS) 查询 AWS 外部的 MySQL 数据库?
- rust - std::thread::JoinHandle::join 如何捕捉恐慌?
- c++ - 以某种方式读取文件中的数据
- wordpress - Docker 容器占用 27GB 磁盘空间,而 docker container ls --size 仅报告 500MB
- python - Python Selenium Ajax jquery:如何知道 jquery(引导程序)何时完成更新页面,以便我可以截屏
- orm - ODOO 问题将行汇总到标题支付模型
- yfinance - 如何使用 Python 的 yfinance 获取每日市值
- java - 您可以完全或在其内部重用 CompletableFuture 对象吗?CompletableFuture 中的一劳永逸
- next.js - react-google-recaptcha 未捕获的类型错误