Amazon EC2 インスタンスで nodeJS サーバーを実行しようとしていますが、パブリックにアクセスできません。
これに関するいくつかのSOの質問といくつかのブログ投稿を読みましたが、解決策はありません。これは私のサーバー構成です:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Simple server\n');
}).listen(4444);
console.log('Server running');
これは次の出力ですiptables -l
。
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:4444
ACCEPT tcp -- anywhere anywhere tcp spt:4444
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp spt:4444
また、ポート4444
はインスタンスのセキュリティ グループにも追加されます。
サーバーが起動した後、実行curl localhost:4444
すると、予想される「Simple Server」がエコーされます。しかし、パブリック DNS / IP アドレスに接続できません。
どの設定がまだ不足しているか知っていますか?