节点JS"世界,你好"服务器上的AWS [英] Node JS "Hello world" server on AWS

查看:103
本文介绍了节点JS"世界,你好"服务器上的AWS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在AWS上运行Hello World的服务器t1.micro实例。我做了什么:

I tried to run "Hello world" server on AWS t1.micro instance. What I done:

  • 我在AWS上安装节点
  • 在写的东西是这样的:


require("http").createServer(function(request, response){
      response.writeHeader(200, {"Content-Type": "text/plain"});  
        response.write("Hello World!");  
          response.end();
}).listen(8080);


  - 它运行在AWS上:节点test_server.js


- Run it on aws: node test_server.js

现在我试图从我的本地机器发送请求到服务器是这样的:

Now I try to send request from my local machine to server like this:

卷曲的http://名称:8080 其中,NAME是AWS控制台的公共DNS名称,但没有任何反应。 我忘了?或者是我做错了

curl http://NAME:8080 where NAME is public DNS name from aws console, but nothing happens. What I forget? Or what I done wrong

我试图寻找一个某种形式的教程,但他们描述了如何在本地计算机上运行此或建议设置Ngnx。但我找极简例如

I tried to look for a some kind of tutorial but they describe how to run this on local machine or propose to setup Ngnx. But I look for minimalist example

推荐答案

您需要告诉亚马逊授权8080端口,您的实例的入站流量。见一步说明步骤文档

You need to tell Amazon to authorize inbound traffic on the 8080 port to your instance. See the documentation for the step by step instructions.

在短期:

  • 进入亚马逊EC2控制台,点击的实例的,打开的安集团的preference窗格
  • 在添加新的规则授权入站流量从任何IP( 0.0.0.0/0 )在端口8080
  • 应用更改:现在的节点网络服务器应能满足HTTP请求
  • Go to the Amazon EC2 console, click on Instance and open the Security Group preference pane
  • Add a new rule authorizing inbound traffic from any IP (0.0.0.0/0) on port 8080
  • Apply changes: the Node web server should now be able to serve HTTP requests.

这篇关于节点JS"世界,你好"服务器上的AWS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆