httpls

0.1.1 • Public • Published

TLS Server with HTTP Redirect

Put this in front of your app and HTTP requests will be redirected to their TLS equivalent.

Usage

var http = require('http'),
    httpls = require('httpls'),
    fs = require('fs');

var options = {
  key: fs.readFileSync('test/fixtures/keys/agent2-key.pem'),
  cert: fs.readFileSync('test/fixtures/keys/agent2-cert.pem')
};

var app = http.createServer(function(req, res) {
  res.writeHead(200);
  res.end("hello, secure world\n");
});
var server = httpls.createServer(options, app);
server.listen(1337);

What happen?

HTTP requests to the listening port will be served a 301 'moved permanently' redirect to the requested location with the scheme changed to https. All other URI attributes are preserved.

curl -I http://localhost:1337/
HTTP/1.1 301 Moved Permanently
Location: https://localhost:1337/
curl https://localhost:1337/
hello, secure world

Readme

Keywords

none

Package Sidebar

Install

npm i httpls

Weekly Downloads

3

Version

0.1.1

License

none

Last publish

Collaborators

  • glenn-murray