Warning: Permanently added 'ec2-18-204-18-81.compute-1.amazonaws.com,18.204.18.81' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-1021-aws x86_64)
...
ubuntu@ip-172-31-83-152:~$
Copy the code of your admin backend to your remote server
There are many ways to copy the code of your admin backend to a remote server. For example, you can use rsync command, or use a versioning system like git.
We strongly advise to version the code of your admin backend using git and host it to a private repository on Github, Bitbucket, Gitlab or other providers.
rsync
rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files. It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program.
Rsync is typically used for synchronizing files and directories between two different systems.
(source: )
In the example above, we use a SSH connection to transfer the file and we connect to the remote server using an identity_file (a private key).
Option
Description
-a
archive mode; same as -rlptgoD (no -H)
-v
increase verbosity
-z
compress file data during the transfer
-e
specify the remote shell to use
--exclude=PATTERN
exclude files matching PATTERN
--progress
show progress during transfer
Once done, you can find the code of your admin backend on the home directory of your remote server.
ssh -i ~/.ssh/aws.pem ubuntu@ec2-18-204-18-81.compute-1.amazonaws.com
ubuntu@ip-172-31-83-152:~$ cd Quickstart/
ubuntu@ip-172-31-83-152:~/QuickStart$ ls -l
total 5116
-rw-r--r-- 1 ubuntu ubuntu 1386 Oct 22 08:11 app.js
-r-------- 1 ubuntu ubuntu 1692 Oct 23 12:51 aws.pem
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 12 10:19 bin
-rw-r--r-- 1 ubuntu ubuntu 5126311 Oct 12 11:20 database.dump
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 19 11:49 forest
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 19 12:22 models
-rw-r--r-- 1 ubuntu ubuntu 69568 Oct 22 07:30 package-lock.json
-rw-r--r-- 1 ubuntu ubuntu 717 Oct 22 07:30 package.json
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 12 10:19 public
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 22 07:48 routes
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 19 11:53 serializers
drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 19 11:55 services
ubuntu@ip-172-31-83-152:~/QuickStart$
git
First, you need to initialize a git repository for the code of your admin backend. From the directory of your admin backend, simply run:
git init
Then, you can add all the files and create your first commit.
git add .
git commit -am "First commit"
Finally, you can add your git remote and push the code on your favorite platform. To do so, first create a new QuickStart repository on your github account. Then run the following command after changing YourAccount to your account name:
Then, we will create a new DB user and schema from the remote server:
sudo -u postgres psql
postgres=# CREATE USER forest WITH ENCRYPTED PASSWORD 'secret';
postgres=# CREATE DATABASE forest_demo;
postgres=# GRANT ALL PRIVILEGES ON DATABASE forest_demo TO forest;
postgres=# \q
Then, you can restart your server to take these new variables into account or simply type:
for env in $( cat /etc/environment ); do export $(echo $env | sed -e 's/"//g'); done
Run your admin backend
From your admin backend's directory, simply type:
npm start
> QuickStart@0.0.1 start /home/ubuntu/QuickStart
> node ./bin/www
🌳 Your back office API is listening on port 3000 🌳
🌳 Access the UI: http://app.forestadmin.com 🌳
Manage Application with PM2
Install PM2
sudo npm install pm2 -g
Run your admin backend using PM2
pm2 start bin/www
(Optional) Set Up Nginx as a Reverse Proxy Server
Now that your admin backend is running and listening on localhost:3310, we will set up the Nginx web server as a reserve proxy to allow your admin panel's users access it.
sudo apt install nginx
To do so, edit (with sudo access) the file located /etc/nginx/sites-available/default and replace the existing section location / by this one:
That's it, your admin backend is now listening on the port 80. Make sure your firewall allows inbound traffic from this port.
The FOREST_ENV_SECRET and FOREST_AUTH_SECRET environment variables will be given by Forest after creating a production environment from the interface. .
Congrats, your admin backend is now running on production. But we strongly advise you to continue following the next steps. If you chose not to do it, you can go back to your Forest interface to create a production environment. .
The admin backend is by default listening on port 3310. Be sure you authorized the inbound traffic on this port or set up a web server (like NGINX) as a to use the port 80.
PM2 is a Production Runtime and Process Manager for Node.js applications with a built-in Load Balancer. It allows you to keep applications alive forever, to reload them without downtime and facilitate common Devops tasks. source: ​
We now require that you configure HTTPS (port 443) on your admin backend service for security reasons. ​
Once you've completed the above steps, it does not mean your project is deployed to production on Forest Admin. To deploy to production, check out .