Skip to content

Instantly share code, notes, and snippets.

@straps
Last active November 3, 2022 09:58
Show Gist options
  • Save straps/6d07ef879d2d6723ad6e3077f22469b0 to your computer and use it in GitHub Desktop.
Save straps/6d07ef879d2d6723ad6e3077f22469b0 to your computer and use it in GitHub Desktop.
Very simple unsecure self-signed HTTPS to HTTP nodejs proxy
var httpProxy = require('http-proxy');
var pem = require('pem');
pem.createCertificate({ days: 1, selfSigned: true }, function (err, keys) {
var httpsOptions = {
key: keys.serviceKey,
cert: keys.certificate
};
httpProxy.createServer({
target: {
host: '0.0.0.0',
port: 3000
},
ssl: httpsOptions
}).listen(4000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment