【问题标题】:Nodejs App at 0.0.0.0:80 not public0.0.0.0:80 的 Nodejs 应用程序未公开
【发布时间】:2013-05-19 14:55:11
【问题描述】:

我正在使用运行 ubuntu 和 nodejs 的 ec2 服务器。我认为这会创建一个有效的服务器,如果我访问我的 ec2 网址,它就会响应。

var http = require("http");
var port = 80; 
var serverUrl = "0.0.0.0";
console.log("Starting web server at " + serverUrl + ":" + port); http.createServer(      
function(req, res) {
  timestamp = new Date();
  console.log("Request for URL " + req.url + " received at " + timestamp);
  if (req.url === '/error') {
    console.log('Throwing an error');
    throw "Oops";
  }
  res.end("Hello World " + timestamp);
}).listen(port, serverUrl);

我用过 nodejs 并且特别是 express 有一段时间了,但从来没有尝试过自己在 vps 上部署它,任何建议都值得赞赏。

【问题讨论】:

标签: node.js amazon-web-services amazon-ec2 vps


【解决方案1】:

确保您在 EC2 安全组上打开了端口 80。

使用机器命令行中的curl 测试它是否在端口 80 上响应。

curl -v http://localhost/

如果它通过本地 curl 应答,您可能只是遇到了防火墙问题。

【讨论】:

  • 谢谢,我也有同样的问题。但测试证明它没问题 - 'connected [...] Accept: /',虽然应用程序似乎挂在 0.0.0.0
猜你喜欢
  • 2019-03-30
  • 2016-09-15
  • 2020-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-24
  • 2019-06-23
相关资源
最近更新 更多