Notice
This article is old, and some of the information may be outdated or no longer valid.
If you have any questions or need to confirm any details, we recommend contacting our support team for up-to-date information and personalized assistance.
Parse Server is a backend (BaaS) that greatly speeds up application development by providing SDKs for platforms such as Android, iOS, PHP, JavaScript, and Unity, among other available environments. This allows developers to avoid having to create an API, drastically reducing development time.
It also includes features such as an administration dashboard, push notifications, third-party login integration with Facebook, Google, or Apple, registration and password recovery emails, and many other capabilities.
Below, we explain in detail the steps required to install Parse-Server and Parse-Dashboard and create a Let's Encrypt SSL certificate with nGinx to secure connections on an Ubuntu 20.04 server on Clouding.
Environment requirements
- Ubuntu 20.04
- MongoDB
- NodeJS
- Yarn
- nGinx
- Let's Encrypt
Open the required ports in the Clouding firewall
The ports used by Parse Server and Parse Dashboard are 1337 and 4040, respectively. However, since we are going to generate SSL certificates with Let's Encrypt, you must use port 1338 externally for Parse Server and ports 80 and 443 for Parse Dashboard. We will use nGinx as a proxy server to forward traffic to ports 1337 and 4040.
Firewall
To open the required ports in the Clouding panel, follow the steps at this link: How to create a firewall rule.
The result should look like this:
Installing MongoDB
Although Parse Server supports both MongoDB and Postgresql, we chose the former because it offers better integration, performance, and an easier initial setup, as there is no need to create an initial schema as there is with PostgreSql.
To install MongoDB, run the following commands:
# apt update# apt upgrade# apt install mongodb-server -y# systemctl status mongodbroot@parse-tutorial:~/parse-server# systemctl status mongodb
● mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-04-01 15:19:12 CEST; 29min ago
Docs: man:mongod(1)
Main PID: 554 (mongod)
Tasks: 34 (limit: 2280)
Memory: 180.7M
CGroup: /system.slice/mongodb.service
└─554 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.confThese commands prepare the database server so that Parse Server can store data.
Installing NodeJS and the Yarn package manager
To deploy both Parse-Server and Parse-Dashboard, you must install the latest stable version of NodeJS. We will also install the Yarn package manager to make installing both easier. To do this, run the following series of commands:
Add the NodejS repository.
# curl -sL https://deb.nodesource.com/setup_lts.x | bash -Install the latest stable version of NodeJS.
# apt install nodejs -yInstall the yarn package manager.
# npm install -g yarnCheck the installed Node version.
# node --version
v14.16.0You now have all the dependencies needed to install Parse Server and the Dashboard.
Installing Parse Server
Installing Parse Server with the Yarn package manager is very straightforward. Run the following command:
# yarn global add parse-serverCreate the "config.json" file, where you will specify the Parse server configuration.
# mkdir parse-server
# cd parse-server
# vi config.jsonCopy the following content:
{
"appName": "Clouding Parse Server",
"databaseURI": "mongodb://localhost:27017/parsedb",
"appId": "418627a8-de68-4989-ad28-5dc5802887eb",
"javascriptKey" : "418627a8-de68-4989-ad28-5dc5802887eb",
"restAPIKey" : "418627a8-de68-4989-ad28-5dc5802887eb",
"clientKey" : "418627a8-de68-4989-ad28-5dc5802887eb",
"masterKey": "4938193c-3d20-4243-9eb9-031ca1ce9f18",
"serverURL": "http://localhost:1337/parse",
"publicServerURL": "https://9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host:1338/parse",
"port": 1337
}Start the Parse server.
# nohup parse-server config.json &Check that the Parse Server port is listening.
# ss -ant | grep 1337
LISTEN 0 511 0.0.0.0:1337 0.0.0.0:*Once the Parse server is installed, you can install the Dashboard to simplify day-to-day server administration.
Installing Parse Server Dashboard
As in the previous section, installing the Dashboard is straightforward with the following command:
# yarn global add parse-dashboardCreate the "parse-dashboard-config.json" file.
# vi parse-dashboard-config.jsonCopy the following configuration.
{
"apps": [
{
"serverURL": "https://9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host:1338/parse",
"appId": "418627a8-de68-4989-ad28-5dc5802887eb",
"masterKey": "4938193c-3d20-4243-9eb9-031ca1ce9f18",
"allowInsecureHTTP": "true",
"appName": "Clouding Parse App"
}
],
"users": [
{
"user":"Clouding",
"pass":"12345"
}
]
}Start the Dashboard.
# nohup parse-dashboard --dev --config ./parse-dashboard-config.json &Check that the Parse Server port is listening.
# ss -ant | grep 4040
LISTEN 0 511 0.0.0.0:4040 0.0.0.0:*
Great! Both the Parse server and the Dashboard are now installed.
Installing and configuring nGinx
You must use nGinx as a reverse proxy for Parse Server and Parse Dashboard. This also makes it easier to install SSL certificates and benefit from automatic renewals without having to access and configure the server every three months. Follow these steps:
Install nGinx.
# apt install -y nginxCheck the status of the nGinx service.
# systemctl status nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-04-01 15:19:13 CEST; 49min ago
For this example, we use the identifier included with each Clouding VPS. In this case, "9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host".
Create the file for the new domain you will be working with:
# vi /etc/nginx/sites-available/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.hostCopy the following configuration. As you can see, port 80 forwards traffic to the dashboard's port 4040, and port 1338 forwards traffic to the Parse server's port 1337.
server {
listen 80;
server_name 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host;
location / {
proxy_pass http://127.0.0.1:4040/;
}
}
server {
listen 1338;
server_name 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host;
location / {
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:1337/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
# enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 300;
}
}
Create the symbolic link to enable the new site.
# ln -s /etc/nginx/sites-available/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host /etc/nginx/sites-enabled/Check that the configuration is correct.
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart the nGinx service.
# systemctl restart nginxOnce the nGinx server is configured, you can create the SSL certificate to use the https protocol.
Installing the SSL certificate with Let's Encrypt
You will need to use Let's Encrypt SSL certificates. To do so, install Let's Encrypt as follows:
# apt install certbot python3-certbot-nginxCreate the certificate for the domain "9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host".
# certbot --installer nginx -d 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.hostAnswer the questions as shown below. Make sure the process finishes successfully with the message "Congratulations! Your certificate and chain have been saved at:".
Saving debug log to /var/log/letsencrypt/letsencrypt.log
How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Nginx Web Server plugin (nginx)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 1
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): clouding@clouding.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled
https://9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/privkey.pem
Your cert will expire on 2021-06-30. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
Edit the "9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host" file again to configure port 1338 to use SSL as well.
# vi /etc/nginx/sites-available/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.hostEdit it to look like this:
server {
server_name 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host;
location / {
proxy_pass http://127.0.0.1:4040/;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 1338 ssl;
server_name 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host;
location / {
proxy_pass http://127.0.0.1:1337/;
}
ssl_certificate /etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name 9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host;
return 404; # managed by Certbot
}That's it! You can now securely access your Parse-Server and Parse-Dashboard with a Let's Encrypt SSL certificate.
Accessing the Parse Dashboard
To access the Dashboard, open a browser and go to the URL https://9a5d1810-92bf-44f0-a0bd-a880724d9f96.clouding.host where you should see the following login window.
Enter the credentials configured earlier and click "Log In". You should see the following Dashboard, where you can start working.
Configuring Parse-Server and Parse-Dashboard as system services with Systemd
To avoid having to start the Parse Server and Parse Dashboard services manually every time the server restarts, follow these steps:
# cd /etc/systemd/system/Create the following service configuration file.
# vi parse.server.serviceCopy the following content.
[Unit]
Description=Parse Server service
After=mongodb.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/local/bin/parse-server /root/parse-server/config.json
[Install]
WantedBy=multi-user.targetStart and enable the service.
# systemctl start parse.server.service
# systemctl enable parse.server.serviceDo the same for the Dashboard service.
# vi parse.server.dashboard.service
Copy the following configuration.
[Unit]
Description=Parse Server Dashboard service
After=parse.server.service
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/local/bin/parse-dashboard --dev --config /root/parse-server/parse-dashboard-config.json
[Install]
WantedBy=multi-user.targetStart and enable the service.
# systemctl start parse.server.dashboard.service
# systemctl enable parse.server.dashboard.serviceChecking that the environment works
One of the easiest ways to check that the installation is working correctly is to go to your Dashboard > API Console > Rest Console. Fill in the fields as shown below to create a new user and click "Send Query".
Go to Browser > User and check that the user you created is available.
With the steps detailed in this tutorial, you now have your own Parse server ready to develop applications faster and more securely. We hope you found it helpful! :)