http2s
Redirect HTTP requests to HTTPS
Installation
Install with npm (https://www.npmjs.com/package/http2s)
npm install http2s
Usage
http2s([options,] [callback])
Calls callback(err, activeSettings)
on done
CLI usage
Command line usage (requires global install npm install --global http2s
)
http2s [httpPort] [hostname]
Listens on http://hostname:httpPort/*
and 302 redirects all requests to https://hostname/
.
Options
Below options are the default values
var settings = {
http: 80,
https: 443,
hostname: 'localhost',
auto: true,
redirectStatus: 302,
singleTarget: false,
message: 'Perhaps you are looking for ' +
'<a href="%s" target="_self">the HTTPS site</a>?',
messageType: 'text/html',
messageStatus: 404,
logLevel: 2
};
Examples
If you are using port numbers >1000 because of permission issues, listen to that port instead.
http2s({
hostname: 'localhost',
http: 8080
});
License
Licensed under Creative Commons CC0 1.0 Universal. All rights waived.
See LICENSE for more information.
Disclaimer
Use at own risk.