Skip to content

Instantly share code, notes, and snippets.

@stfsy
Last active June 5, 2021 19:57
Show Gist options
  • Save stfsy/3e056c266021d5b873534da1f7ab49c5 to your computer and use it in GitHub Desktop.
Save stfsy/3e056c266021d5b873534da1f7ab49c5 to your computer and use it in GitHub Desktop.
ExpressJS configuration for SSL with Let's Encrypt certificates
'use strict'
const fs = require('fs')
const constants = require('crypto').constants
const spdy = require('spdy')
const server = require('express')
const app = express()
const port = process.env.port || 3000
const srv = spdy.createServer({
secureOptions: constants.SSL_OP_NO_SSLv2 | constants.SSL_OP_NO_SSLv3 | constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1,
key: fs.readFileSync('/etc/letsencrypt/live/monitoring.blauspecht.io/privkey.pem', 'utf-8'),
cert: fs.readFileSync('/etc/letsencrypt/live/monitoring.blauspecht.io/cert.pem', 'utf-8'),
spdy: {
plain: false // do not allow unencrypted traffic
}
}, app)
srv.listen(port, () => {
logger.info('Yup, running on port ' + port)
logger.info('NODE_ENV = ' + process.env.NODE_ENV)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment