https-detect
Detect whether a stream is https or http based on the first buffer on a stream and forward accordingly.
example
simple.js
Listen on :4050
routing http traffic to :4051
and https traffic to :4052
.
var httpsDetect = ;;
route.js
Fire up http and https servers and route traffic to them based on what the incoming messages look like.
var httpsDetect = ;var http = ;var https = ;var fs = ;var opts =key : fscert : fs;var servers =http : httphttps : https;servershttp;servershttps;;
output:
$ curl http://localhost:4050
I am an http server!
$ curl -k https://localhost:4050
I AM TOTALLY SECURE AND STUFF YOU GUYS. SELF SIGNED IS TOTALLY SECURE, WHATEVER.
$
methods
var httpsDetect = ;
httpsDetect(opts)
opts should have 2 keys:
- http - the http server
[port,host]
- https - the https server
[port,host]
host
defaults to localhost for both keys.
If the option argument isn't an array it will be lifted to be [port]
.
install
With npm, do:
npm install https-detect
license
MIT/X11