Installing Nodejs , NPM and NVM
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
~/.nvm/nvm.sh
nvm install node
Cross Check Installed Versions
node -v
npm -v
nvm --version
Clone Source Code
git clone https://github.com/saurabharch/rollout
npm install
yarn install
./node_modules/.bin/web-push generate-vapid-keys
cp env.example /config/.env
node src/index.js
Setup your app for Remote Push Notifications using the
docs
and download the Remote Push Notifications certificate .cer
files
for Development and Production. Import them both into your keychain.
Open Keychain Access and export both the certificate and private key
(highlight them both) to a .p12
file. I recommend saving them as:
apns_dev_Certificates.p12
apns_prod_Certificates.p12
Then create the corresponding .pem
files:
#dev
openssl pkcs12 -clcerts -nokeys -out apns_dev_cert.pem -in apns_dev_Certificates.p12
openssl pkcs12 -nocerts -out apns_dev_key.pem -in apns_dev_Certificates.p12
#prod
openssl pkcs12 -clcerts -nokeys -out apns_prod_cert.pem -in apns_prod_Certificates.p12
openssl pkcs12 -nocerts -out apns_prod_key.pem -in apns_prod_Certificates.p12
# optional to remove passphrase from keys
openssl rsa -in apns_dev_key.pem -out apns_dev_key.unencrypted.pem
openssl rsa -in apns_prod_key.pem -out apns_prod_key.unencrypted.pem
Copy the *.pem
files into the certs
folder of this repo.
./gen-cert.sh example.com
npm install -g pm2
Run as root user in Linux
sudo pm2 start --name server-name index.js -- --name server-name --port 5500 --watch
sudo pm2 start --name server-name index.js
sudo pm2 startup
sudo pm2 save
โ๐ป PREQUESTS
sudo apt-get install nginx
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt install python-certbot-nginx
Generate SSL Certificate using certbot command
sudo certbot --nginx -d pushgeek.com -d www.pushgeek.com
Alternate Command
sudo certbot certonly --standalone -d pushgeek.com www.pushgeek.com
Auto Renewal Certficate with certbot
sudo certbot --dry-run
ALLOW PORTS FOR NGINX AND SETUP FIREWALL
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo ufw enable
sudo ufw allow http
sudo ufw allow https
sudo ufw status
sudo ufw status
sudo ufw allow 443/tcp
(should required)systemctl status nginx
sudo vim /etc/nginx/sites-available/rollout
sudo ln -s sites-available/rollout sites-enable/rollout
sudo nginx -t
sudo service nginx restart
sudo /etc/init.d/nginx reload
sudo journalctl -xe
sudo systemctl status nginx
installing fail2ban protecting DDoS
sudo apt-get install fail2ban
Fail2ban Configuration with Nginx
File Structure
|
|
|________________________./congif
| |
| |____keys_prod.js
| |
| |____keys_dev.js
| |
| |____keys.js
|
|
|________________________./public
| |
| |____index.html
| |
| |____sw.js
| |
| |____app.js
|
|
|________________________./model
| |
| |____subscribers_model.js
|
|
|
|________________________./router
| |
| |____push.js
| |
| |____subscribe.js
| |____keygen.js
|
|___________________________server.js