簡體   English   中英

永遠的Express JS不監聽外部IP

[英]Express js with forever does not listen to external ip

我已將我的express js應用程序上傳到具有靜態IP的VPS。

我的偵聽端口和主機的代碼是這樣的:

app.listen(8888, "0.0.0.0");

然后,我將永遠永遠開始:

forever start main.js

當我通過本地主機打開我的頁面時,我嘗試通過外部ip地址打開它,但無法訪問。

我錯過了什么?

我在Ubuntu Server 14.04中的iptables是這樣的:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:8888

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

主要有趣的是,我可以通過SSH遠程訪問此VPS。

您是否有iptables等防火牆? 在這種情況下,您可能需要打開端口8888。

sudo iptables -A INPUT -p tcp --dport 8888 -j ACCEPT

請注意,如果重新啟動服務器,此規則將丟失。 參見https://askubuntu.com/questions/66890/how-can-i-make-a-specific-set-of-iptables-rules-permanent

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM