Server Hosting


A lightweight platform ideal for building fast, scalable network applications in Javascript. Similar in design to Ruby's Event Machine or Python's Twisted, and built on Chrome's JavaScript runtime, NodeJS is ideal for data-intensive apps that run across distributed devices.

What I get
A server installation with the NodeJS together with NPM, NGINX, PM2.

Getting started after deploying NodeJS
After you created a server, you can navigate to its public IPv4 address to see the sample application live.
You will then be prompted to enter a password. If you created your server with a root user password, enter this in the terminal. If you created your server with an ssh key, enter the passphrase associated with your key.

To learn how to make modifications or get your code onto your server, here are the steps. You can also follow the sample application for the instructions.

Step 1: Access to your server
Open a terminal on your computer to access your server as the root user using the following command:

ssh root@your_server_public_ipv4

Step 2: Make modifications to the sample application
Modify this script at /var/www/html/hello.js. You can then see the results live by using pm2, a process manager that schedules your code to run at boot time. The application runs as the nodejs user, so changes to pm2 need to be run as the nodejs user.
sudo -u nodejs pm2 restart hello

Step 3: Get your code on here
Clone your NodeJS code onto the server, anywhere you like. Note: If you're not using a source control, you can directly upload the files to your server using SFTP.
Cd into the directory where your NodeJS code lives, and install any dependencies. (For example, if you have a package.json file, run npm install.)

Launch your app
sudo -u nodejs pm2 start your-file

Map the port your app run on to an HTTP URL
nano /etc/nginx/sites-available/default

Edit the existing entry that exposes the "hello" app at port 3000 to the world so that it points to your app’s port instead.
Enable your new nginx config.
sudo systemctl restart nginx

Call to schedule your code to run at launch.
sudo -u nodejs pm2 save

Repeat these steps for any other NodeJS apps that need to run concurrently -- schedule them to run at boot time on whatever internal port you like using PM2, then map that port to an HTTP/HTTPS URL in the nginx config. Build out the URL directory structure you need by mapping applications to URL paths; that's the reverse proxy method in a nutshell!

Now you can delete the sample app we installed on your server. Stop running the initial script (that you’re viewing now)
sudo -u nodejs pm2 delete hello

Stop it from running on server boot.
sudo -u nodejs pm2 save

Step 4: Get production-ready
There's a lot you'll want to do to make sure you're production-ready. Here are the popular things that people will do.
Non-root user: Set up a non-root user for day-to-day use
Firewall: Review your firewall settings by calling sudo ufw status, and make any changes you need. By default, only SSH/SFTP (port 22), HTTP (port 80), and HTTPS (port 443) are open. You can also disable this firewall by calling sudo ufw disable and use a 25Space cloud firewall instead, if you like (they're free).

Domain: Register a custom domain
Storage: You can mount a volume (up to 16TB) to this server to expand the filesystem, provision a database cluster (that runs MySQL, Redis, or PostgreSQL), or use a Space, which is an S3-compatible bucket for storing objects.

Good to know
The pre-installation refers only to the first setup/installation of the server and not to further operation. Once the installation is complete, you will have administrative access to the systems. You are responsible and liable for the further operation, administration, updates and changes.
The server can be reached via SSH.

  • Startup to connecto via SSH to your server
  • Don't forget the security.

It might be interesting for you too:

Deploy now