Question

I want to run a node.js app on amazon ec2 instance. here's what I have done.

npm install -g yo
npm install -g generator-angular
yo angular
grunt serve

and this is the snippet of the Gruntfile.js

// The actual grunt server settings
connect: {
  options: {
    port: 9000,
    // Change this to '0.0.0.0' to access the server from outside.
    hostname: '0.0.0.0',
    livereload: 35729
  },
  livereload: {
    options: {
      open: true,
      base: [
        '.tmp',
        '<%= yeoman.app %>'
      ]
    }
  },
  test: {
    options: {
      port: 9001,
      base: [
        '.tmp',
        'test',
        '<%= yeoman.app %>'
      ]
    }
  },
  dist: {
    options: {
      base: '<%= yeoman.dist %>'
    }
  }
}

I want to see the sample angular page when I access my ec2 instance from web browser at port 80.

What should I do to accomplish this?

Was it helpful?

Solution

For this you can use a proxy such as nginx

sudo yum install nginx

Then you just update the location section of the /etc/nginx/nginx.conf to proxy your port 9000:

<snip>
server {
    listen       80;
    server_name  localhost;

    location / {
        proxy_pass  http://127.0.0.1:9000/;
    }
</snip>

restart the nginx service:

sudo service nginx restart

and that should do it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top