summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2019-04-24 21:53:12 -0400
committerFranklin Wei <me@fwei.tk>2019-04-24 21:53:12 -0400
commit87eba42a2fa234f1619a0d3e89f92e0a06876f2e (patch)
treee2a124583fb4145cd6ab965b959d8c3b58b9853b
parent9d8fa7296c2be049798959ef048bb4cba108dd49 (diff)
downloadtennisdraw-87eba42a2fa234f1619a0d3e89f92e0a06876f2e.zip
tennisdraw-87eba42a2fa234f1619a0d3e89f92e0a06876f2e.tar.gz
tennisdraw-87eba42a2fa234f1619a0d3e89f92e0a06876f2e.tar.bz2
tennisdraw-87eba42a2fa234f1619a0d3e89f92e0a06876f2e.tar.xz
Add SSL
-rw-r--r--draw.js2
-rw-r--r--server.js11
2 files changed, 11 insertions, 2 deletions
diff --git a/draw.js b/draw.js
index 7f2ee59..6659556 100644
--- a/draw.js
+++ b/draw.js
@@ -271,7 +271,7 @@ function doPerformSort(players, callback)
{
if(typeof performSort === 'undefined')
{
- var url = "http://fwei.tk:8080";
+ var url = "https://fwei.tk:8080";
$.ajax({
url:url,
type:"POST",
diff --git a/server.js b/server.js
index 61fa797..df5817e 100644
--- a/server.js
+++ b/server.js
@@ -1,3 +1,10 @@
+const fs = require('fs');
+const https = require('https');
+
+var privkey = fs.readFileSync('/etc/letsencrypt/live/fwei.tk/privkey.pem', 'utf8');
+var cert = fs.readFileSync('/etc/letsencrypt/live/fwei.tk/cert.pem', 'utf8');
+var cred = {key: privkey, cert: cert};
+
const express = require('express');
const sort = require('./sort.js');
const app = express();
@@ -27,4 +34,6 @@ app.post('/', function(request, response){
response.end();
});
-app.listen(port, () => console.log(`Example app listening on port ${port}!`))
+var httpsServer = https.createServer(cred, app);
+httpsServer.listen(port);
+console.log("listening on port " + port);