diff options
author | Noah Loomans <noahloomans@gmail.com> | 2017-03-02 10:01:35 +0100 |
---|---|---|
committer | Noah Loomans <noahloomans@gmail.com> | 2017-03-02 10:01:35 +0100 |
commit | 5e22bfbf5a719dea902da2363e4a4a36be484ea2 (patch) | |
tree | 6f81677e099c040aa223a69d2061879cd645e8ce /bin/www | |
parent | b0a28236a486a757d6b0a0a013d4f9301ecd8170 (diff) | |
parent | e7b00ae239925b1c6364d80b86cc7001c316d991 (diff) |
Merge branch 'useHTTPS' into beta
Diffstat (limited to 'bin/www')
-rwxr-xr-x | bin/www | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -5,9 +5,14 @@ const app = require('../app') const http = require('http') const https = require('https') +const fileLocations = { + cert: '/etc/letsencrypt/live/rooster.hetmml.nl/fullchain.pem', + privkey: '/etc/letsencrypt/live/rooster.hetmml.nl/privkey.pem' +} + function setupHTTPS () { - const certificate = fs.readFileSync('/etc/letsencrypt/live/rooster.hetmml.nl/fullchain.pem', 'utf8') - const privateKey = fs.readFileSync('/etc/letsencrypt/live/rooster.hetmml.nl/privkey.pem', 'utf8') + const certificate = fs.readFileSync(fileLocations.cert, 'utf8') + const privateKey = fs.readFileSync(fileLocations.privkey, 'utf8') const credentials = { key: privateKey, cert: certificate } const httpsPort = normalizePort(process.env.PORT_HTTPS || '3001') @@ -88,7 +93,7 @@ function onListening (server) { let useHTTPS = true try { - fs.accessSync('/etc/letsencrypt/live/rooster.hetmml.nl/privkey.pem') + fs.accessSync(fileLocations.privkey) } catch (e) { useHTTPS = false } @@ -102,7 +107,7 @@ if (useHTTPS) { setupHTTP() } } else { - console.warn('NOT USING HTTPS! Could not read /etc/letsencrypt/live/rooster.hetmml.nl/privkey.pem') + console.warn(`NOT USING HTTPS! Could not read ${fileLocations.privkey}`) setupHTTP() } |