mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Changed some https stuff
This commit is contained in:
parent
cfe9706e31
commit
c53c181a5b
1 changed files with 18 additions and 20 deletions
38
server.js
38
server.js
|
@ -18,7 +18,7 @@
|
|||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
const startHTTPS = false;
|
||||
const startHTTPS = true;
|
||||
const siteUrl = "https://qmining.tk"; // http(s)//asd.basd
|
||||
const ircURL = "https://kiwiirc.com/nextclient/irc.sub.fm/#qmining";
|
||||
|
||||
|
@ -48,21 +48,26 @@ const logFile = "stats/logs";
|
|||
const allLogFile = "/nlogs/log";
|
||||
|
||||
// https://certbot.eff.org/
|
||||
const privkeyFile = "/etc/letsencrypt/live/questionmining.tk/privkey.pem";
|
||||
const fullchainFile = "/etc/letsencrypt/live/questionmining.tk/fullchain.pem";
|
||||
const chainFile = "/etc/letsencrypt/live/questionmining.tk/chain.pem";
|
||||
const privkeyFile = "/etc/letsencrypt/live/qmining.tk/privkey.pem";
|
||||
const fullchainFile = "/etc/letsencrypt/live/qmining.tk/fullchain.pem";
|
||||
const chainFile = "/etc/letsencrypt/live/qmining.tk/chain.pem";
|
||||
|
||||
var certsLoaded = false;
|
||||
if (startHTTPS && utils.FileExists(privkeyFile) && utils.FileExists(fullchainFile) && utils.FileExists(chainFile)) {
|
||||
const key = fs.readFileSync(privkeyFile, "utf8");
|
||||
const cert = fs.readFileSync(fullchainFile, "utf8");
|
||||
const ca = fs.readFileSync(chainFile, "utf8");
|
||||
var certs = {
|
||||
key: key,
|
||||
cert: cert,
|
||||
ca: ca
|
||||
};
|
||||
certsLoaded = true;
|
||||
try {
|
||||
const key = fs.readFileSync(privkeyFile, "utf8");
|
||||
const cert = fs.readFileSync(fullchainFile, "utf8");
|
||||
const ca = fs.readFileSync(chainFile, "utf8");
|
||||
var certs = {
|
||||
key: key,
|
||||
cert: cert,
|
||||
ca: ca
|
||||
};
|
||||
certsLoaded = true;
|
||||
|
||||
} catch (e) {
|
||||
logger.Log("Error loading cert files!", logger.GetColor("redbg"));
|
||||
}
|
||||
}
|
||||
|
||||
const port = 8080;
|
||||
|
@ -73,13 +78,6 @@ var highlights = ["public", "static", "manual", "isgetting", "postfeedback",
|
|||
];
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
//app.all('*', function(req, res, next) {
|
||||
// if(req.secure) {
|
||||
// next();
|
||||
// } else {
|
||||
// res.redirect('https://' + req.hostname + req.url);
|
||||
// }
|
||||
//});
|
||||
app.use(function(req, res, next) {
|
||||
res.on('finish', function() {
|
||||
Log(req, true, res.statusCode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue