Cannot get nodejs working on amazon ec2 instance

I have been trying to run the nodejs server on a micro-instance of amazon for the last 3-4 days without success.

I followed a lot of tutorials, and I can’t get the server to work (therefore, when it is visited in a browser or broken in PowerShell and see a simple hello world).

Here are the last 3 tutorials I've tried:

http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/ http://techprd.com/setup-node-js-web- server-on-amazon-ec2 / http://devblog.daniel.gs/2014/01/deploying-node-apps-on-aws-ec2-with.html

I tried ubuntu / amazon linux.

I also followed http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/install-LAMP.html to see how the overall process works and it works great.

I get to the point where I am doing something like: sudo node filename.js and the server is working.

However, when I try to visit or twist it. he does not work. when I ping, it pings great.

in amazon, I set up a security group to basically allow it like this:

enter image description here

on linux I stuck to it: https://help.ubuntu.com/community/IptablesHowTo?action=show&redirect=Iptables to open the port that I was trying to listen to and nothing.

when I print: sudo service iptables statusI get:

1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1337:1347

2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpts:1338:1348

3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:10000

Keep in mind that I'm not an experienced guy.

Any help would be greatly appreciated.

UPDATE: node, , nodejs.org:

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

+4
1

, .

  • node ? Ec2 curl -v localhost:8000 ( - , node.) . , node.js .

  • nginx? curl -v localhost. 80. - , , , nginx.

  • IP-? / curl -v x.x.x.x, x.x.x.x IP2- EC2. , .

  • DNS? (, foo.com ) curl -v http://foo.com/. , DNS .

, . .

, .

+3

Source: https://habr.com/ru/post/1527030/


All Articles