Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created August 3, 2019 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/864951c103896fede56b42d09af14085 to your computer and use it in GitHub Desktop.
Save ryanlid/864951c103896fede56b42d09af14085 to your computer and use it in GitHub Desktop.
http sever && https server
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