• Stars
    star
    1,181
  • Rank 39,604 (Top 0.8 %)
  • Language
    JavaScript
  • Created almost 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ” Free, automated HTTPS for NodeJS made easy.

No longer maintained!

js-standard-style Join the chat at https://gitter.im/DylanPiercey/auto-sni

Auto SNI

SSL Certificates using SNI with almost zero configuration for free with https://letsencrypt.org!

If you have any questions, throw them up on gitter.

Installation

Npm

npm install auto-sni

Features

  • Fetch SSL certificates from letsencrypt.
  • Automatically renew certificates.
  • Forward all incoming http requests to https.

Example

var createServer = require("auto-sni");

var server = createServer({
  email: ..., // Emailed when certificates expire.
  agreeTos: true, // Required for letsencrypt.
  debug: true, // Add console messages and uses staging LetsEncrypt server. (Disable in production)
  domains: ["mysite.com", ["test.com", "www.test.com"]], // List of accepted domain names. (You can use nested arrays to register bundles with LE).
  dir: "~/letsencrypt/etc", // Directory for storing certificates. Defaults to "~/letsencrypt/etc" if not present.
  ports: {
    http: 80, // Optionally override the default http port.
    https: 443 // // Optionally override the default https port.
  }
});

// Server is a "https.createServer" instance.
server.once("listening", ()=> {
  console.log("We are ready to go.");
});

Usage with express.

var createServer = require("auto-sni");
var express      = require("express");
var app          = express();

app.get("/test", ...);

createServer({ email: ..., domains: ..., agreeTos: true }, app);

Usage with koa.

var createServer = require("auto-sni");
var koa          = require("koa");
var app          = koa();

app.use(...);

createServer({ email: ..., domains: ..., agreeTos: true }, app.callback());

Usage with rill.

var createServer = require("auto-sni");
var rill         = require("rill");
var app          = rill();

app.get("/test", ...);

createServer({ email: ..., domains: ..., agreeTos: true }, app.handler());

Usage with hapi.

// Untested (Let me know in gitter if this doesn't work.)
var createServer = require("auto-sni");
var hapi         = require("hapi");
var server       = new hapi.Server();
var secureServer = createServer({ email: ..., domains: ..., agreeTos: true });

server.connection({ listener: secureServer, autoListen: false, tls: true });

Usage with restify.

// Untested (Let me know in gitter if this doesn't work.)
var createServer = require("auto-sni");
var restify      = require("restify");
var app          = restify.createServer({ name: 'myapp', version: '1.0.0' });

app.get("/test", ...);

createServer({ email: ..., domains: ..., agreeTos: true }, app.server);

Dynamic Domains

You can also specify an async function to approve domains like so:

createServer({
  ...,
  domains: (options, cert, cb) => {
    setTimeout(() => cb({ options, cert }), 1000)
  }
})

Root Access

AutoSNI requires access to low level ports 80 (http) and 443 (https) to operate by default. These ports are typically restricted by the operating system.

In production (on linux servers) you can use the following command to give Node access to these ports.

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

For development it's best to set the "ports" option manually to something like:

{
  ports: {
    http: 3001,
    https: 3002
  }
}

// Access server on localhost:3002

Rate Limits

Currently LetsEncrypt imposes some rate limits on certificate creation. Click here for the current rate limits.

Contributions

Please use npm test for tests and feel free to create a PR!

More Repositories

1

set-dom

๐Ÿ“‘ Lightweight dom diffing with plain old html.
JavaScript
185
star
2

local-devices

๐Ÿ”ฎ Find devices connected to the current local network.
JavaScript
140
star
3

vdo

๐Ÿท Minimal JSX compatible html focused templating engine.
JavaScript
82
star
4

tusk

UNMAINTAINED - A slim virtual dom implementation.
JavaScript
50
star
5

receptacle

๐Ÿช Multi purpose in memory lru cache with ttl support.
JavaScript
49
star
6

host-proxy

๐Ÿ™‹ Fast, lightweight and transparent http(s) proxy that supports dynamic hostnames.
JavaScript
16
star
7

toll

๐Ÿ™‹โ€โ™‚๏ธ Simple node hostname proxying and registration for micro-services.
JavaScript
16
star
8

parse-form

๐Ÿ“ƒ Utility to easily parse forms in the browser.
TypeScript
13
star
9

Syntux

Highlight.js optimized for browserify and react.
JavaScript
11
star
10

scroll-behaviour

๐Ÿ’ƒ Scroll Behavior polyfill http://iamdustan.com/smoothscroll for universal use.
JavaScript
9
star
11

require-ensure

๐Ÿค Proper require.ensure polyfill for node that is actually async.
JavaScript
9
star
12

set-page

๐Ÿ’† Framework agnostic, isomorphic <html>, <body and <head> rendering utility.
JavaScript
8
star
13

spawn-server-webpack-plugin

๐Ÿ•ดPlugin for automatically starting a node server from memory after building it with Webpack.
TypeScript
8
star
14

loading-tag

Maybefill for a `<loading>` tag which allows for client reordering of async html.
TypeScript
7
star
15

byte-length

๐Ÿ“ Get the real byte length of a string.
TypeScript
7
star
16

mini-querystring

๐ŸŽป Lightweight universal querystring parser.
TypeScript
6
star
17

mini-url

๐Ÿ“– Lightweight universal url parser.
TypeScript
6
star
18

join-url

๐Ÿ‘ฏโ€โ™‚๏ธ Like `path.join` but for urls.
JavaScript
6
star
19

q-flat

๐Ÿฝ Flatten a nested object using query string syntax.
TypeScript
6
star
20

the

โœ… Structured and testable schemas for JavaScript.
JavaScript
5
star
21

marko-vite-fastify-ssg

Marko example using vite, fastify & ssr-to-html to produce a static site.
Marko
5
star
22

as-html

๐Ÿ“„ HTML templating with es6 quasi literals.
JavaScript
5
star
23

htmljs-to-solid-jsx

This is purely an experiment of efficiently compiling Marko's syntax to solid compatible JSX.
TypeScript
5
star
24

is-local-ip

๐Ÿ‘จโ€๐ŸŒพ Check that a given ip address is private.
JavaScript
4
star
25

submit-form

๐Ÿ’พ Utility to easily submit forms in the browser.
JavaScript
4
star
26

benchmark-cli

๐Ÿ‹๏ธโ€โ™€๏ธ CLI application to benchmark JavaScript files.
JavaScript
4
star
27

mocha-snap

File based snapshotting for Mocha tests.
TypeScript
3
star
28

isbrowser

๐Ÿ•ธ A browserify transform to remove server-side code.
JavaScript
3
star
29

mocha-dom

Run Mocha tests in an isolated JSDOM environment.
TypeScript
2
star
30

a-task

๐Ÿ‘ฅ Easily run multiple parallel tasks with node.
JavaScript
2
star
31

fastify-marko-i18n-example

A basic example using Marko + Fastify with i18n
JavaScript
2
star
32

require-load

๐Ÿ—ฃ Asynchronously require files in node.
JavaScript
2
star
33

marko-vite-express-ssr-only

An example showing how to use Marko + Vite with SSR only.
Marko
2
star
34

q-set

๐Ÿด Set a query string style field on an object.
TypeScript
1
star
35

load-stripe

๐Ÿ’ต Load the promisified stripe api in the browser.
JavaScript
1
star
36

md-vars

๐Ÿ“‰ Parse variables from a markdown file in a clean and simple format.
JavaScript
1
star
37

is-typeof

๐Ÿ”ฌ A tool for better type checking in JavaScript.
TypeScript
1
star
38

vite-issue-resolve-id-repro

JavaScript
1
star
39

webpack-dev-server-issue-infinite-reload

https://github.com/webpack/webpack-dev-server/issues/3803
JavaScript
1
star
40

vite-ssr-optimize-deps-cjs-bug

JavaScript
1
star
41

host-to-port

๐Ÿ“ Converts a hostname into a unique valid port.
JavaScript
1
star
42

side-step

๐Ÿ‘€ Intercept Fetch and XHR requests.
JavaScript
1
star
43

vite-ssr-optimize-deps-internals-bug

Importing node internals that ultimately go into SSR optimized deps throws an error.
JavaScript
1
star
44

get-win

Gets the current window/global object in any runtime.
TypeScript
1
star
45

load-frame

Isomorphic browser testing using JSDOM and iframes.
TypeScript
1
star
46

on-event

๐ŸŽค Simpler in-line event delegation for html templates.
JavaScript
1
star