Giter Site home page Giter Site logo

routerjon's Introduction

routerjon

an nodejs expressjs router, giving you outward https encryption with certificates issued from letsencrypt.

basically my script i use for https certs on deployment.

install

npm install -g routerjon

setup

mkdir routerjon
cd routerjon
touch config.json

config json should list the different domains you will use. and to which routerjon should redirect them.

for example the config running on my deployment at blogjono.com is

{
  "ports": {
    "http": 80,
    "https": 443
  },
  "production": true, // server for letsencrypt, note production has rate limit
  "email": "[email protected]",
  "router": { // these are servers already running on the machine
    "blogjono.com": {
      ".": 9000,
      "fcc-pin": 9001,
      "booktrade": 9003
    },
    "opentorah.uk": 9002
  }
}

default config

The default config fills in any gaps missed by your config.

{
  "ports": {
    "http": 3000,
    "https": 3443
  },
  "production": false,
  "spdy": false, // option to use an experimental http2 server
  "domains": {
    "localhost:3000": 9000
  }
}

run

[sudo] routerjon ./conifg.json

run (in background)

nohup routerjon ./config.json

run forever

make sure you are in a directory with a file named exactly config.json

when routerjon crashes it will foreverjs process manager will restart it

[sudo] npm i -g forever
touch routerjon_forever

routerjon_forever file

#!/bin/sh
routerjon ./config.json
[sudo] forever start -c bash routerjon-forever

you may need sudo or root privallages to run the command with the server ports 80 and 443. you will also need to stop any other servers (like nginx, apache) listening on these ports

reload changes

by default when you edit the config with valid json and save the file, changes will be automatically reloaded (thanks to node-watch). This makes it easy to vim into and fiddle with the routers port numbers

run into challenges with letsencrypt

this module uses greenlock v3 to manage certificates which stores the files in ~/.config/greenlock. sometimes you may have to delete this folder if you run into errors in the logs.

suggestions ip-tables

so that the nodejs app does not run as root it is suggested to install and use libcap2

sudo pacman -Syu libcap
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``

details

the script will store your certificates in the ~/letsencrypt directory.

i am not sure the greenlock-express module causes them to autorenew.

author & licence

author: Jonathan T L Lee

licence: MIT

repo: https://github.com/Lee182/routerjon

feel free look around the code. its only 176 lines

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.