【发布时间】: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,因此您可能希望展示您如何运行您的应用程序。