Last active
June 5, 2021 20:10
-
-
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
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
'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