aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2017-03-02 10:00:18 +0100
committerNoah Loomans <noahloomans@gmail.com>2017-03-02 10:00:18 +0100
commite7b00ae239925b1c6364d80b86cc7001c316d991 (patch)
tree6fa6e7f07f3426ef3d28171fe69bb6b0b098e870
parent569828f54965979e6f98b7646a125584b157f071 (diff)
Use http2 on https connections
-rwxr-xr-xbin/www13
-rw-r--r--package.json1
2 files changed, 10 insertions, 4 deletions
diff --git a/bin/www b/bin/www
index ef9dae5..8da634f 100755
--- a/bin/www
+++ b/bin/www
@@ -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()
}
diff --git a/package.json b/package.json
index 184d026..b1e56db 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"morgan": "~1.7.0",
"request": "^2.74.0",
"smoothscroll-polyfill": "^0.3.4",
+ "spdy": "^3.4.4",
"then-yield": "0.0.1"
},
"devDependencies": {