npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dynamic-sni

v1.6.0

Published

Automatically generate tls credentials using letsencrypt.

Downloads

22

Readme

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

Dynamic SNI

It's a fork of 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.
  • If creating a certificate fails it will fall back to a simple self signed certificate.
  • 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).
	forceSSL: true, // Make this false to disable auto http->https redirects (default true).
	redirectCode: 301, // If forceSSL is true, decide if redirect should be 301 (permanent) or 302 (temporary). Defaults to 302
	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: ..., agreeTos: true }, app);

Usage with koa.

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

app.use(...);

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

Usage with rill.

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

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

createServer({ email: ..., 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: ..., 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");

// Override the https module in AutoSNI with restify.
createServer.https = restify;

// Use a special restify option.
var app = createServer({ email: ..., agreeTos: true, restify: true });
app.get("/test", ...);

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 $(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

Location of certificates

For production you may wish to start backing up or distributing the certificates across multiple sersers. Auto-SNI stores the certificates under the ~/letsencrypt folder. During development you may find you need to refresh/reset these cerificates, in which case you can simply remove the directory.

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!