VHTTPS Virtual Host on HTTPS
This minimal package aims to allow hosting multiple HTTPS sites with multiple certificates on a single server/IP address, without the need to use any reverse proxy.
Install
npm install --save vhttps
Usage
Use vhttps.init
:
const vhttps = ; const options = cert: fs key: fs; const cred_a = cert: fs key: fs; const cred_b = cert: fs key: fs; // Create an vhttps instanceconst server = vhttps; // Set HTTPS options (with default certificate)server; // Introduce handlers to different domain namesserver;server; // (optional) Add default handlerserver; // Listen at port 443server;
Use vhttps.init
with Express:
const vhttps = ;const express = ; const options = {}; const router_a = express;router_a; const router_b = express;router_b; const cred_a = cert: fs key: fs; const cred_b = cert: fs key: fs; // Create an vhttps instanceconst server = vhttps; // Introduce handlers to different domain namesserver;server; // Listen at port 443server;
Direct usage for vhttps.createServer
:
const vhttps = ; const defaultCredential = cert: fs key: fs; const credentialA = hostname: 'a.com' cert: fs key: fs; const credentialB = hostname: 'b.com' cert: fs key: fs; const server = vhttps; server;
Direct usage for vhttps.createServer
with Express vhost
:
const fs = ;const express = ;const vhost = ;const vhttps = ; const app = ; app; app; const defaultCredential = cert: fs key: fs; const credentialA = hostname: 'a.com' cert: fs key: fs; const credentialB = hostname: 'b.com' cert: fs key: fs; const httpsServer = vhttps;httpsServer;