javascript - CentOs 中 aws 中的 node.js 应用程序部署不起作用

标签 javascript linux node.js amazon-ec2 centos

当我在 AWS 的 CentOs 6.5 中运行 node.js 应用程序时

var sys = require( "sys" );
var http = require( "http" );
// Create our HTTP server.
var server = http.createServer(
function( request, response ){
// Create a SUPER SIMPLE response.
response.writeHead( 200, {"content-type": "text/plain"} );
response.write( "Hellow world from AWS!\n" );
response.end();
}
);
// Point the HTTP server to port 8080.
server.listen( 3000 );
// For logging....
console.log( "Server is running on 3000" );

它运行并在控制台上显示:
服务器在 3000 上运行

但是当我打开浏览器并运行 亚马逊提供的公共(public) DNS : http://ec2-54-152-55-189.compute-1.amazonaws.com:3000/ ,它显示网页不可用,但在 aws 的 CentOs 终端中,当我运行命令时:curl http://ec2-54-152-55-189.compute-1.amazonaws.com:3000/表明 来自 AWS 的世界,您好!

1)入站规则是
HTTP -- 任何地方
SSH -- 任何地方
自定义 TCP 规则 (PORT-3000)-- 任何地方
HTTPS-- 任何地方
自定义 UDP 规则 (PORT-3000)-- 任何地方
2)出站规则为
所有流量|所有协议(protocol) |所有端口|任何地方

感谢任何帮助。非常感谢。

最佳答案

问题已解决,入站规则设置如下:
HTTP -- 任何地方
SSH -- 任何地方
自定义 TCP 规则 (PORT-3000)-- 任何地方
HTTPS-- 任何地方
自定义 UDP 规则 (PORT-3000)-- 任何地方

在 centOS 6.5 实例中,防火墙不允许来自端口 (HTTP)80、(CUSTOM)3000、(HTTPS)443 的任何连接。因此,我允许所需的端口号。在 iptables 中 看: http://www.cyberciti.biz/faq/howto-rhel-linux-open-port-using-iptables/编辑 iptables 并重新启动防火墙 https://www.digitalocean.com/community/tutorials/how-to-set-up-a-basic-iptables-firewall-on-centos-6允许防火墙中的特定端口

关于javascript - CentOs 中 aws 中的 node.js 应用程序部署不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33751664/

相关文章:

node.js - net::ERR_TOO_MANY_REDIRECTS 如果我想在 puppeteer 中打开网站

javascript - 如何阻止用户使用浏览器的后退按钮或退格键访问上一个jsp页面

Linux 套接字 :no route to host on planetLab machine

linux - 使用分支预测器了解 Spectre 漏洞

linux - 错误 : Invalid or corrupt jarfile occured while trying to build recommendation engine of PredictionIO in Linux machine

mysql - 如何在表中存储数组 MySQL(对于 NodeJS)

node.js - res.send 之后运行函数

每次执行函数时,Javascript ES5 : How to extend the Function object in order to set a property value on itself,?

javascript - GoJS在不知道父节点 key 的情况下删除子节点

javascript - 取消绑定(bind)内联 onClick 在 jQuery 中不起作用?