node.js - 我在 azure VM 上的反应应用程序没有出现
问题描述
我有一个 react.app,我已将代码上传到我公共子网上的 Azure VM 机器。我的网络没有问题,出于开发目的,我释放了安全组上的所有端口,让它们对入站和出站端口没有限制。我还有一个负载平衡,可以通过公共子网引导流量。在我的负载均衡器中,我有将端口 22 和 3000 转发到具有反应代码的后端池和 VM 机器的入站规则。当我使用负载均衡的公共 IP 和端口 3000 时,我仍然无法访问我的网站。
该应用程序在 VM 上启动,但在 PC 上的浏览器中无法访问,我使用的是 20 .. .92:3000
[root@****i]# npm start
> material-kit-pro-react@1.9.0 start /var/tmp/thermo-api
> http-server ./app -a 0.0.0.0 -p 3000 -c-1
Starting up http-server, serving ./app
Available on:
http://127.0.0.1:3000
http://10.0.1.4:3000
Hit CTRL-C to stop the server
任何线索或帮助将不胜感激!
编辑
我可以在 VM 内部 curl 到端口 3000,然后它可以让我访问网页,但是当我 ssh 到 VNET 中的另一个节点时,我仍然可以 ping 到 VM(10.0.1.4),但我无法 curl 到我的 VM 的端口 3000。
[AzureUser@***** ~]$ ping 10.0.1.4
PING 10.0.1.4 (10.0.1.4) 56(84) bytes of data.
64 bytes from 10.0.1.4: icmp_seq=1 ttl=64 time=1.67 ms
64 bytes from 10.0.1.4: icmp_seq=2 ttl=64 time=1.95 ms
64 bytes from 10.0.1.4: icmp_seq=3 ttl=64 time=2.07 ms
64 bytes from 10.0.1.4: icmp_seq=4 ttl=64 time=1.70 ms
64 bytes from 10.0.1.4: icmp_seq=5 ttl=64 time=1.78 ms
64 bytes from 10.0.1.4: icmp_seq=6 ttl=64 time=1.65 ms
64 bytes from 10.0.1.4: icmp_seq=7 ttl=64 time=1.78 ms
64 bytes from 10.0.1.4: icmp_seq=8 ttl=64 time=1.76 ms
^C
--- 10.0.1.4 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 19ms
rtt min/avg/max/mdev = 1.645/1.794/2.069/0.142 ms
[AzureUser@**** ~]$ curl 10.0.1.4:3000
curl: (7) Failed to connect to 10.0.1.4 port 3000: No route to host
我在这里附上了我的虚拟机 iptables
[root@****]# iptables -L -n -v
Chain INPUT (policy ACCEPT 308K packets, 1658M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DOCKER-USER all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 DOCKER-ISOLATION-STAGE-1 all -- * * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- * docker0 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
0 0 DOCKER all -- * docker0 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT all -- docker0 docker0 0.0.0.0/0 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 307K packets, 55M bytes)
pkts bytes target prot opt in out source destination
Chain DOCKER (1 references)
pkts bytes target prot opt in out source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
pkts bytes target prot opt in out source destination
0 0 DOCKER-ISOLATION-STAGE-2 all -- docker0 !docker0 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- * docker0 0.0.0.0/0 0.0.0.0/0
0 0 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
Chain DOCKER-USER (1 references)
pkts bytes target prot opt in out source destination
0 0 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
解决方案
在这种情况下,我有两点要告诉你。
- 检查 Azure VM 内是否有任何防火墙。比如在 Linux 上运行IPTables 之
iptables -L -n -v
类的。检查 IPTables / 防火墙的状态。选项“-L”(列表规则集)、“-v”(详细)和“-n”(以数字格式显示)。如果有,则需要在 VM 防火墙中打开 3000 端口。 - 根据您的要求,您可以创建负载均衡器的入站 NAT 规则。它看起来像这样。
您可以按照本指南对Azure 负载均衡器进行故障排除。如果您有任何问题,请告诉我。
推荐阅读
- macos - 配置:错误:无法构建 Qt 应用程序,可能是由于缺少或太旧的 Qt 包
- c# - 通过主键从外部表中获取数据
- javascript - 有没有办法改进reduce的这种使用?
- ios - NativeScript 将 UIViewController 传递给原生 iOS 方法
- tsql - 查看有多少 sysobjects 使用特定数据库中的表
- php - rsync 运行良好的思想终端,但不使用 php exec
- c# - 2.1 中使用 EF Core 的数据库查询
- c# - 在 C# 中将字符串转换为二维数组
- java - 使用弹出窗口的用户输入:在 Selenium 中
- php - 如何验证特定年份的二月天数?