【问题标题】:Only port 3000 is accessible remotely in web serverWeb 服务器中只能远程访问 3000 端口
【发布时间】:2019-12-17 06:40:08
【问题描述】:

我正在尝试在同一服务器(在不同端口)中托管多个 nodejs 应用程序。

我在 3000,3001 和 3002 端口运行 3 个应用程序。

我能够运行所有三个(成功!)但问题是只有当应用程序在端口 3000 中运行时,它才能通过互联网(邮递员)访问,但是当应用程序在任何其他端口中运行时端口(3001 或 3001..)虽然成功运行,但无法通过 Internet 访问。

在 TCP_IN = "20,443,465,21,22,587,993,25,53,80,110,143,995,3000,3001,3001" 和 TCP_OUT 中添加所有端口后,我尝试更新 csf 文件并重新启动防火墙

app.listen(PORT, () => {
    console.log("Server is running on port: " + PORT)
});

--or--

const PORT = process.env.PORT || 3001;
app.listen(PORT, () => {
    console.log("Server is running on port: " + PORT)
});

--or--

const PORT = process.env.PORT || 3002;
app.listen(PORT, () => {
    console.log("Server is running on port: " + PORT)
});

另外,我刷新了防火墙(iptables)中的所有规则,现在的 iptables 看起来像:

target     prot opt source               destination

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

我希望我应该能够在任何开放端口上运行任何 nodejs 应用程序,并且应该可以通过互联网访问它。

【问题讨论】:

  • 你的iptables输出好像不完整,Chain INPUT部分说了什么?此外,由于您在问题中标记了 pm2,因此您可能希望展示您如何运行您的应用程序。

标签: node.js centos pm2


【解决方案1】:

您似乎遇到了端口问题。我建议您执行以下操作可能对此有所帮助。

  1. 你可以换个端口号试试。

  2. 您可以使用traceroute检查这些端口(3000,30013002)通过 特定的服务器。在此处查看有关 traceroute 的更多信息https://serverfault.com/questions/49235/traceroute-tcp-equivalent-for-windows

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2016-01-07
  • 1970-01-01
  • 1970-01-01
  • 2020-01-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多