Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created December 16, 2019 17:02
Show Gist options
  • Save ryanlid/5df4ff4938ab2b9714a2eadc3778b765 to your computer and use it in GitHub Desktop.
Save ryanlid/5df4ff4938ab2b9714a2eadc3778b765 to your computer and use it in GitHub Desktop.
HTTPS Server by Node.js
const https = require('https');
const fs = require('fs')
const options = {
key: fs.readFileSync('./cert/domain.key'),
cert: fs.readFileSync('./cert/domain.pem')
}
const app = https.createServer(options, (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Hello World!\n')
})
app.listen(4000, '0.0.0.0')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment