Skip to content
This repository has been archived by the owner on Jul 31, 2021. It is now read-only.

Commit

Permalink
howdy pardner.
Browse files Browse the repository at this point in the history
  • Loading branch information
minotaa committed Sep 26, 2020
1 parent 6c48b80 commit 8227b60
Show file tree
Hide file tree
Showing 3 changed files with 2,012 additions and 1,672 deletions.
32 changes: 20 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const cookieParser = require('cookie-parser')
const bodyParser = require('body-parser')
const session = require('express-session')
const https = require('https')
const http = require('http')
const fs = require('fs');
const app = express();
const helmet = require('helmet')
Expand Down Expand Up @@ -120,15 +121,22 @@ app.use((req, res, next) => {
});

/** Start the listener */
const privateKey = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/chain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate,
ca: ca
};
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(443, () => {
console.log('Server started listening on port 443!');
});
try {
const privateKey = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/privkey.pem', 'utf8');
const certificate = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/cert.pem', 'utf8');
const ca = fs.readFileSync('/etc/letsencrypt/live/sketchel.art/chain.pem', 'utf8');
const credentials = {
key: privateKey,
cert: certificate,
ca: ca
};
const httpsServer = https.createServer(credentials, app);
httpsServer.listen(443, () => {
console.log('Server started listening on port 443!');
});
} catch(e) {
const httpServer = http.createServer(app)
httpServer.listen(8000, () => {
console.log('Server started listening on port 8000!');
})
}
Loading

0 comments on commit 8227b60

Please sign in to comment.