Skip to content

tripolskypetr/pwalauncher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pwalauncher

The microservice bootstrap for PWA with serverless functions

Usage

npm install -g pwalauncher
pwalauncher # Will share `wwwroot` subfolder with static assets and redirect to `index.html` if 404

Benefits

  1. Free SSL Certificate obuse

Create a ZeroSSL 90-days sertificate for single domain and multiply it to several websites shared on different ports

  1. Port forward over SSL

Forwarding https://example.com/8081 to http://localhost:8081. Both websoket and http forwarding are supported

  1. JWT Validation for each forwarded port

While forwarding to http://localhost:8081 the pwalauncher can intercept Authorization: Bearer <token> header and validate the token. The UI can sign a token every 10 seconds to avoid DDOS

  1. CRA-like API proxy

Request to https://example.com/v1 can be forwarded to https://cloud.appwrite.io/v1

  1. Cors-everywhere like file download proxy

Fetch from https://example.com/cors/http://filedownload.com/demo.mp3 will download http://filedownload.com/demo.mp3 ignoring mixed content and cord origin policy

  1. Mutal SSL auth on a server side

A self-signed SSL certificate installed localy can be used to restrict access to application authorisation with second layer of authentification

Ecosystem

This tool is extreamly powerfull with PM2. The pm2 should be used for instantiation while pwalauncher used as easy-config reverse-proxy

pm2 start ecosystem.config.js
pm2 list
pm2 save
pm2 monit
pm2 stop service
pm2 kill

The tmux also can be used to start microservices in debug mode with direct stdin/stdout pipe

tmux kill-session
tmux
tmux attach
Ctrl + B + D
Ctrl + B + C
Ctrl + B + P
Ctrl + B + N

The pwalaunch used single argument if you want to use different name of config.

pwalaunch launcher.config.json

Configutation

const fs = require('fs');

module.exports = {
    ports: [
        8081,
        8082,
        8083,
        8084,
        8085,
        8086,
        8087,
        8088,
        8089,
        8090,
    ],
    proxy: [
        {
            path: 'v1',
            link: 'http://127.0.0.1:8080/v1'
        }
    ],
    ssl: {
        key: fs.readFileSync('./ssl/private.key', 'utf8'),
        cert: fs.readFileSync('./ssl/certificate.crt', 'utf8'),
    },
    sslPort: 444,
    sslVerify: true,
    jwtSecret: "TEST",
    cookieSecret: true, // { key: "test", value: "1", }
    cookieSecretAllowed: ['/', '/index.html', '/favicon.ico'],
    ipBlacklist: ["95.173.136.72"],
    port: 80,
    redirectHttps: false,
    wwwroot: "build"
};

Self-signed SSL Setup

If you getting trouble while trying to setup self-signed ssl, check the 3rdparty folder. The SSLCertificateMaker.exe will help you create root certificate (CA) for client devices and self-signed children (CERT) for the server. The CertTrustManager.exe will help you create a one-button setup file for root certificate (CA), to create that file right click on CertTrustManager window.

screenshot

P.S. If you choose wrong certificate in modal run chrome://restart to choose It again or use Edge