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 run Angular project on server

Angular is the most used frontend programming language in website development. We can Develop modern, complex, responsive, and scalable web applications with Angular
With this article, I will guide you on how we can make run our angular project on a live server I have used Digital Ocean and Google cloud server to live our project
I have used Ubuntu 20

You must have a node with npm installed on a server if not you can install by following the command

apt update

sudo apt install nodejs npm

You can check the node version by running the following command

node -v

install the Angular CLI globally with:

npm install -g @angular/cli

Go to the project root folder

To download and install npm packages, use the following npm CLI command:

npm install

Use the following CLI command to run your application locally:

ng serve

by default angular take port 4200 and you can see your project running with  http://youipaddress:4200/ If the default port 4200 is not available, you can specify another port with the port flag as in the following

 

ng serve --port 4200

If you are not able to see your project with your IP address run the following

ng serve --host 0.0.0.0

 

Now if you want to run your project with PM2 to keep the application in the background  follow the following step 

npm install -g pm2 
pm2 start "ng serve"
pm2 start "ng serve --host 0.0.0.0"

pm2 start "ng serve --host 0.0.0.0 --port 4200"
pm2 start "ng serve --host 0.0.0.0 --port 4200" --name "MyApp"
pm2 status

Hope this will help you to make you angular application live on server
Read more...