Setup Parse Server
- Create new droplet for parse server
- Ubuntu 16.04.2
- 512 MB
- 20 GB SSD
- NY1/2/3
- name: test.goexploremichigan.com
- Wait for server to be setup
- Copy server ip address
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04
ssh root@[server ip address]
- Get password for new server from email sent by Digital Ocean
- Create a new root password (Make sure you save this in a password manager!)
adduser michigander
- Create a password for the new user (Make sure you save this in a password manager as well!)
- skip through (hit enter) the rest of the steps, they are not required
usermod -aG sudo michigander
Add SSH Key Note: I assume you have a ssh key setup on your computer.
su - michigander
mkdir ~/.ssh
chmod 700 ~/.ssh
vim ~/.ssh/authorized_keys
- On your local machine:
pbcopy < ~/.ssh/id_rsa.pub
- Insert mode:
i
- Paste the your public key
- Save:
esc
,:wq
,enter
chmod 600 ~/.ssh/authorized_keys
exit
Disable Password Authentication
sudo vim /etc/ssh/sshd_config
- Insert mode:
i
- Verify:
- PasswordAuthentication no (this should be the only one you have to change)
- PubkeyAuthentication yes
- ChallengeResponseAuthentication no
- Save:
esc
,:wq
,enter
sudo systemctl reload sshd
Test SSH Login
In a new terminal tab do the following:
ssh michigander@[server IP address]
- Create a new A record in your domain name's DNS settings and set it to your server's IP address
- Example: Record Type: A, Name: test, Value: [server's ip address], TTL: 600 seconds
- Now we can test logging into our server with our custom domain name
ssh michigander@test.goexploremichigan.com
Note: It may take some time for the DNS settings to update.
sudo apt-get install letsencrypt
sudo letsencrypt certonly --standalone -d test.goexploremichigan.com
- Enter in email address
- Agree to terms
sudo apt-get update
sudo apt install npm
curl -sL https://deb.nodesource.com/setup_6.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install nodejs
sudo apt-get install build-essential
sudo npm install -g parse-server
sudo apt-get install nginx
sudo vim /etc/nginx/sites-enabled/default
- Delete the contents of the file:
dG
- Insert mode:
i
- Copy and paste in example below
- Save:
esc
,:wq
,enter
- Reload nginx:
sudo service nginx reload
# HTTP - redirect all requests to HTTPS
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server
server {
listen 443;
server_name test.goexploremichigan.com;
root /usr/share/nginx/html;
index index.html index.htm;
ssl on;
# Use certificate and key provided by Let's Encrypt:
ssl_certificate /etc/letsencrypt/live/test.goexploremichigan.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.goexploremichigan.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
# Pass requests for /parse/ to Parse Server instance at localhost:1337
location / {
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://localhost:1337/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
#location / {
# try_files $uri $uri/ =404;
#}
}
Store the following environment variables in ~/.bashrc
.
vim ~/.bashrc
- Insert mode:
i
- Paste the example environment variables in the file
- Save:
esc
,:wq
,enter
- Reboot server:
sudo reboot
# PARSE ENVIRONMENT VARIABLES
export PARSE_SERVER_APPLICATION_ID="exploremichigan"
export PARSE_SERVER_DATABASE_URI="mongodb://michigander:BjWT7uJ4mqDh7DxNNjEcz7MV3mWHyA7mn3h4U2hhNoDuck2QHwvM4fnoBnG7bfRu@ds112300.mlab.com:44381/test-goexploremichigan"
export PARSE_SERVER_MASTER_KEY="9B04B992-D07A-4CEC-A6BF-49018D556929"
export PARSE_SERVER_REST_API_KEY="F11A810A-ACFC-4F67-B5E3-B2EFBD8DAD97"
export PARSE_SERVER_URL="http://localhost:1337/parse"
export PORT="1337"
export PARSE_SERVER_ALLOW_CLIENT_CLASS_CREATION=false
#export PARSE_SERVER_CLOUD_CODE_MAIN="/home/username/cloud/main.js"
- Start:
parse-server
You can now verify it is working by hitting it in your browser. https://test.goexploremichigan.com/parse