aws ec2 public ip根本不工作

时间:2015-02-09 19:15:45

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

我是AWS的新手。成功启动了EC2 windows 2012 r2实例,我可以通过远程桌面服务登录。安装了一个nodejs应用程序,它在localhost:80上成功运行。但是,问题在于公共IP。我尝试了许多解决方案,比如添加入站安全规则等...我甚至终止了实例并重新启动了一个新实例,但没有用。

服务器详细信息: AWS EC2:Windows 2012 R2

当我尝试通过公共DNS访问时,它说“网页不可用”。我的公共IP是http://ec2-54-169-173-68.ap-southeast-1.compute.amazonaws.com/

以下是ping结果:

C:\Users\srujan>ping ec2-54-169-173-68.ap-southeast-1.compute.amazonaws.com

Pinging ec2-54-169-173-68.ap-southeast-1.compute.amazonaws.com [54.169.173.68] with 32 bytes of data:
Reply from 54.169.173.68: bytes=32 time=51ms TTL=118
Reply from 54.169.173.68: bytes=32 time=51ms TTL=118
Reply from 54.169.173.68: bytes=32 time=49ms TTL=118
Reply from 54.169.173.68: bytes=32 time=43ms TTL=118

Ping statistics for 54.169.173.68:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds:
Minimum = 43ms, Maximum = 51ms, Average = 48ms

ping结果显示什么? 公共IP是否正常工作?

请让我知道解决方案。我试了好几个小时后就无助了。如果需要更多细节来解决问题,请告诉我。

提前致谢。

修改

Fiddler结果在浏览器中:

[Fiddler] The connection to 'ec2-54-169-173-68.ap-southeast-1.compute.amazonaws.com' failed. 
Error: TimedOut (0x274c). 
System.Net.Sockets.SocketException A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 54.169.173.68:80

Fiddler在Fiddler窗口中的结果:

Request Count:   1
Bytes Sent:      413        (headers:413; body:0)
Bytes Received:  719        (headers:207; body:512)

ACTUAL PERFORMANCE
--------------
ClientConnected:    09:38:03.718
ClientBeginRequest: 09:38:03.735
GotRequestHeaders:  09:38:03.735
ClientDoneRequest:  09:38:03.735
Determine Gateway:  0ms
DNS Lookup:         0ms
TCP/IP Connect: 21007ms
HTTPS Handshake:    0ms
ServerConnected:    09:38:24.745
FiddlerBeginRequest:    00:00:00.000
ServerGotRequest:   00:00:00.000
ServerBeginResponse:    00:00:00.000
GotResponseHeaders: 00:00:00.000
ServerDoneResponse: 00:00:00.000
ClientBeginResponse:    09:38:24.745
ClientDoneResponse: 09:38:24.745

Overall Elapsed:    0:00:21.009

RESPONSE BYTES (by Content-Type)
--------------
text/html: 512
~headers~: 207


ESTIMATED WORLDWIDE PERFORMANCE
--------------
The following are VERY rough estimates of download times when hitting  servers based in Seattle.

US West Coast (Modem - 6KB/sec)
    RTT:        0.10s
    Elapsed:    0.10s

Japan / Northern Europe (Modem)
    RTT:        0.15s
    Elapsed:    0.15s

China (Modem)
    RTT:        0.45s
    Elapsed:    0.45s

US West Coast (DSL - 30KB/sec)
    RTT:        0.10s
    Elapsed:    0.10s

Japan / Northern Europe (DSL)
    RTT:        0.15s
    Elapsed:    0.15s

China (DSL)
    RTT:        0.45s
    Elapsed:    0.45s


________________
Learn more about HTTP performance at http://fiddler2.com/r/?HTTPPERF

2 个答案:

答案 0 :(得分:2)

发现问题。它没有端口号或防火墙。问题在于node.js程序。

错误是:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(80, '127.0.0.1');
console.log('Server running at http://127.0.0.1:80/');

我把它改为:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen( 80 );
console.log('Server running at 80');

我刚刚删除了localhost的ip地址。工作正常。

但是,感谢您的快速回复和支持。

答案 1 :(得分:0)

ping仅告诉您实例正在接受并回复icmp个数据包。它有助于确定路线是否存在问题,但无法帮助您识别所有问题。

您的问题归结为两种可能的选择之一:

  1. 防火墙阻止与端口80的连接。这可以包括安全组和Windows内部防火墙。
  2. 您的网络服务器未绑定到网络接口。 Web服务器可以配置为绑定到接口提供的单个IP,或者监听所有这些IP。您还可以将站点绑定到环回,这使得它只能自行访问。