🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

httpls

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpls

Redirect HTTP requests to HTTPS

latest
Source
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

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

Keywords

node

FAQs

Package last updated on 20 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts