DEV Community

jswalker.in
jswalker.in

Posted on

Node.js on port 80 in AWS

First step to AWS

You'll get the fresh machine after register with AWS.
But they provide a user that does not have the power of root. You can write root command with 'sudo su' but launching Node.js process on 80 port is difficult it always gives you The EACCESS Error. Because of Security reasons (For a Reason).

But as a single/Minimal team, you have a handful and trusted people. So you can make that bet on to get access with root with few adjustments at root level.

:Caution:
Take a backup of every file that you change mostly in /etc folder.

Install Node.js

After installing node.js you'll notice that 80 port already occupied either from Nginx/Apache WebServer.

Steps to configure Node.js on 80 port

  1. Open ssh to ubuntu(AWS) with ssh key(Old one)

  2. Write command "sudo su" to gain sudo power

  3. Write command "nano etc/ssh/sshd_config"

  4. look for PasswordAuthentication tag and change its value 'yes'

  5. Login to root and password (If this is first time set new password with passwd)

  6. Generate new public and private key in putty generator and keep Public-key ssh-header locally.

    Alt Text

  7. Paste (Public-Key:ssh-header) from PuttyGen to /root/.ssh/authorized_keys

  8. Keep Private and Public key safe for login via public-key from "ssh-client" such as putty :
    {Username:root,Method:Public-key} Add/Import your openSSH private key to your SSH-Client's Client-Key-Manager.

    Alt Text

  9. sudo service sshd restart

  10. Login with ssh now

    Alt Text

  11. You may disable the password login and only allow ssh key again. By setting "PasswordAuthentication no" (Recommended) or you may still allow root access with password(Not recommended).

Stop preoccupied service on port 80

Before executing node.js process need to kill occupied 80 port process.

sudo fuser -k 80/tcp

Go Ahead

Go-Ahead run Node.js on port 80 it will work.

Tip:

Use Node.js for APIs.Static assets should serve via NginX.Keep use Multiple database layer for smooth operation.

Latest comments (0)