Created
August 3, 2019 16:18
-
-
Save ryanlid/864951c103896fede56b42d09af14085 to your computer and use it in GitHub Desktop.
http sever && https server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const https = require("https"); | |
const fs = require("fs"); | |
const express = require("express"); | |
const app = express(); | |
// http server | |
const http_server = http.createServer(app); | |
http_server.listen(80, "0.0.0.0"); | |
const options = { | |
key: fs.readFileSync("./cert/xx.key"), | |
cert: fs.readFileSync("./cert/xx.cert") | |
}; | |
// https server | |
const https_server = https.createServer(options, app); | |
https_server.createServer(443, "0.0.0.0"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment