How to enable port on cloud server using ufw

UFW, or the “Uncomplicated FireWall”, UFW use iptables to manage it’s firewall rules, you may need this while your are using ubuntu or Debian server.

it’s very simple to use

Firstly instal UFW using following command

apt-get install ufw

You can then set it to allow outgoing traffic and reject incoming traffic by default with the following commands:

ufw default allow outgoing
ufw default allow outgoing

You will need to then enable the firewall:

ufw enable

You can then open specific ports using the following command (remember to replace $PORT with the port number you wish to open, and $PROTOCOL with either tcp or udp:

ufw allow $PORT/$PROTOCOL

If you are looking to open the same port for TCP and UDP, you can just leave out the /$PROTOCOL part:

ufw allow $PORT

Read more...

How to keep node server running in background

When you work with node js with a local environment you can keep your server active with the npm start command and access API.

but when you have to make your project live you may want all APIs should work continuously and perform all job backgrounds.

You can achieve this by PM2

you need to install pm2 and run this command

pm2 start npm -- start

if you want have name for better recongnization you can write unique name by follwing command 

pm2 start npm --name "app name" -- start

he app name will be unique name for you server

 

Read more...