From a7526ffad86cfeca65c1599827c84dba5002c848 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Thu, 31 Oct 2019 06:46:35 -0600 Subject: [PATCH] v3.0.8: update deps, add example --- examples/http-proxy.js | 37 +++++++++++++++++++++++++++++++++++++ package-lock.json | 14 +++++++------- package.json | 4 ++-- 3 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 examples/http-proxy.js diff --git a/examples/http-proxy.js b/examples/http-proxy.js new file mode 100644 index 0000000..04dd42f --- /dev/null +++ b/examples/http-proxy.js @@ -0,0 +1,37 @@ +"use strict"; + +require("@root/greenlock-express") + .init(function getConfig() { + return { package: require("../package.json") }; + }) + .serve(httpsWorker); + +function httpsWorker(glx) { + var proxy = require("http-proxy").createProxyServer({ xfwd: true }); + + // we need the raw https server + var server = glx.httpsServer(); + + // catches error events during proxying + proxy.on("error", function(err, req, res) { + console.error(err); + res.statusCode = 500; + res.end(); + return; + }); + + // We'll proxy websocketts too + server.on("upgrade", function(req, socket, head) { + proxy.ws(req, socket, head, { + ws: true, + target: "ws://localhost:1443" + }); + }); + + // servers a node app that proxies requests to a localhost + glx.serveApp(function(req, res) { + proxy.web(req, res, { + target: "http://localhost:3000" + }); + }); +} diff --git a/package-lock.json b/package-lock.json index d0ecdf4..2164bbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,9 +40,9 @@ "integrity": "sha512-OaEub02ufoU038gy6bsNHQOjIn8nUjGiLcaRmJ40IUykneJkIW5fxDqKxQx48cszuNflYldsJLPPXCrGfHs8yQ==" }, "@root/greenlock": { - "version": "3.0.12", - "resolved": "https://registry.npmjs.org/@root/greenlock/-/greenlock-3.0.12.tgz", - "integrity": "sha512-jizQNf4OZcEugm875IBnd8GR78fkU6leLbq44ARJYX8ot/VKShEZpus5n/mTzrJHMgrQvFJU2mkPGJmG0+yvzg==", + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/@root/greenlock/-/greenlock-3.0.17.tgz", + "integrity": "sha512-1XKhcLFEx1WFdn1Bc2rkAE/SL1ZUJYYMZdbnehTrfhCr5Y+9U1gdkNZnR/jInhoUvcicF/PXuZkGVucU50RNUg==", "requires": { "@root/acme": "^3.0.8", "@root/csr": "^0.8.1", @@ -51,7 +51,7 @@ "@root/request": "^1.3.10", "acme-http-01-standalone": "^3.0.5", "cert-info": "^1.5.1", - "greenlock-manager-fs": "^0.7.0", + "greenlock-manager-fs": "^3.0.1", "greenlock-store-fs": "^3.2.0", "safe-replace": "^1.1.0" } @@ -106,9 +106,9 @@ "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" }, "greenlock-manager-fs": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/greenlock-manager-fs/-/greenlock-manager-fs-0.7.0.tgz", - "integrity": "sha512-cWmrfdSbT0ettDZzl6SXhZ47gVLj7saM/tdEP6sEfnsocJ3mRFRP3QUrJYyLVdCOCuVH6cclOKLembIrZjwDrQ==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/greenlock-manager-fs/-/greenlock-manager-fs-3.0.1.tgz", + "integrity": "sha512-vZfGFq1TTKxaAqdGDUwNservrNzXx0xCwT/ovG/N378GrhS+U5S8B8LUlNtQU7Fdw6RToMiBcm22OOxSrvZ2zw==", "requires": { "@root/mkdirp": "^1.0.0", "safe-replace": "^1.1.0" diff --git a/package.json b/package.json index b59cd24..0b6e7a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@root/greenlock-express", - "version": "3.0.7", + "version": "3.0.8", "description": "Free SSL and managed or automatic HTTPS for node.js with Express, Koa, Connect, Hapi, and all other middleware systems.", "main": "greenlock-express.js", "homepage": "https://greenlock.domains", @@ -17,7 +17,7 @@ "example": "examples" }, "dependencies": { - "@root/greenlock": "^3.0.12", + "@root/greenlock": "^3.0.17", "redirect-https": "^1.1.5" }, "trulyOptionalDependencies": {