Skip to content

Instantly share code, notes, and snippets.

@stfsy
Last active June 5, 2021 20:10
Show Gist options
  • Save stfsy/d9b100627b54b1bb2ea3bae9098bd98d to your computer and use it in GitHub Desktop.
Save stfsy/d9b100627b54b1bb2ea3bae9098bd98d to your computer and use it in GitHub Desktop.
ExpressJS server, that redirects traffic to https and answers Lets Encrypt acme challenge webroot requests directly
'use strict'
const spdy = require('spdy')
const express = require('express')
const port = process.env.port || 8080
const app = express()
app.use('/.well-known/acme-challenge/', express.static('./certbot/.well-known/acme-challenge/', {
dotfiles: 'allow'
}))
app.use((req, res) => {
res.writeHead(301, {
'Location': 'https://www.blauspecht.io'
})
res.end()
})
const server = spdy.createServer({
spdy: {
plain: true
}
}, app)
server.listen(port, () => {
logger.info('Insecure redirect server running on port ' + port)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment