mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
support for https
This commit is contained in:
parent
963b81864c
commit
a6bf04f8d4
20
bin/www
20
bin/www
@ -10,7 +10,9 @@ process.on('unhandledRejection', error => {
|
|||||||
|
|
||||||
const app = require('../app');
|
const app = require('../app');
|
||||||
const debug = require('debug')('node:server');
|
const debug = require('debug')('node:server');
|
||||||
|
const fs = require('fs');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const https = require('https');
|
||||||
const config = require('../services/config');
|
const config = require('../services/config');
|
||||||
const log = require('../services/log');
|
const log = require('../services/log');
|
||||||
|
|
||||||
@ -23,9 +25,23 @@ app.set('port', port);
|
|||||||
/**
|
/**
|
||||||
* Create HTTP server.
|
* Create HTTP server.
|
||||||
*/
|
*/
|
||||||
const server = http.createServer(app);
|
let server;
|
||||||
|
|
||||||
log.info("App server starting up at port " + port);
|
if (config['Network']['https']) {
|
||||||
|
const options = {
|
||||||
|
key: fs.readFileSync(config['Network']['keyPath']),
|
||||||
|
cert: fs.readFileSync(config['Network']['certPath'])
|
||||||
|
};
|
||||||
|
|
||||||
|
server = https.createServer(options, app);
|
||||||
|
|
||||||
|
log.info("App HTTPS server starting up at port " + port);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
server = http.createServer(app);
|
||||||
|
|
||||||
|
log.info("App HTTP server starting up at port " + port);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen on provided port, on all network interfaces.
|
* Listen on provided port, on all network interfaces.
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
[Network]
|
[Network]
|
||||||
port=80
|
port=80
|
||||||
|
# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).
|
||||||
|
https=false
|
||||||
|
# path to certificate (run "bash generate-cert.sh" to generate self-signed certificate). Relevant only if https=true
|
||||||
|
certPath=
|
||||||
|
keyPath=
|
||||||
|
|
||||||
[Sync]
|
[Sync]
|
||||||
syncServerHost=
|
syncServerHost=
|
||||||
|
@ -1,16 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
openssl genrsa -des3 -out cert.key 2048
|
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 2000 -nodes
|
||||||
|
|
||||||
openssl req -new -key cert.key -out cert.csr
|
|
||||||
|
|
||||||
# Remove passphrase from key
|
|
||||||
cp cert.key cert.key.org
|
|
||||||
|
|
||||||
openssl rsa -in cert.key.org -out cert.key
|
|
||||||
|
|
||||||
# Generate self signed certificate
|
|
||||||
openssl x509 -req -days 730 -in cert.csr -signkey cert.key -out cert.crt
|
|
||||||
|
|
||||||
rm cert.key.org
|
|
||||||
rm cert.csr
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user