mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Add host option (#588)
* Added option to configure host * Updated sample config
This commit is contained in:
parent
3d7a5f20e7
commit
dcebcb0e73
@ -3,6 +3,8 @@
|
|||||||
instanceName=
|
instanceName=
|
||||||
|
|
||||||
[Network]
|
[Network]
|
||||||
|
# host setting is relevant only for web deployments - set the host on which the server will listen
|
||||||
|
# host=0.0.0.0
|
||||||
# port setting is relevant only for web deployments, desktop builds run on random free port
|
# port setting is relevant only for web deployments, desktop builds run on random free port
|
||||||
port=8080
|
port=8080
|
||||||
# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).
|
# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).
|
||||||
|
10
src/services/host.js
Normal file
10
src/services/host.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const config = require('./config');
|
||||||
|
const env = require('./env');
|
||||||
|
|
||||||
|
let environmentHost;
|
||||||
|
|
||||||
|
if (process.env.TRILIUM_HOST) {
|
||||||
|
environmentHost = process.env.TRILIUM_HOST;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Promise.resolve(environmentHost || config['Network']['host'] || '0.0.0.0');
|
7
src/www
7
src/www
@ -25,6 +25,7 @@ const messagingService = require('./services/messaging');
|
|||||||
const utils = require('./services/utils');
|
const utils = require('./services/utils');
|
||||||
const sqlInit = require('./services/sql_init');
|
const sqlInit = require('./services/sql_init');
|
||||||
const port = require('./services/port');
|
const port = require('./services/port');
|
||||||
|
const host = require('./services/host');
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
|
|
||||||
if (!semver.satisfies(process.version, ">=10.5.0")) {
|
if (!semver.satisfies(process.version, ">=10.5.0")) {
|
||||||
@ -36,8 +37,10 @@ let httpServer;
|
|||||||
|
|
||||||
async function startTrilium() {
|
async function startTrilium() {
|
||||||
const usedPort = await port;
|
const usedPort = await port;
|
||||||
|
const usedHost = await host;
|
||||||
|
|
||||||
app.set('port', usedPort);
|
app.set('port', usedPort);
|
||||||
|
app.set('host', usedHost);
|
||||||
|
|
||||||
if (config['Network']['https']) {
|
if (config['Network']['https']) {
|
||||||
if (!config['Network']['keyPath'] || !config['Network']['keyPath'].trim().length) {
|
if (!config['Network']['keyPath'] || !config['Network']['keyPath'].trim().length) {
|
||||||
@ -70,7 +73,7 @@ async function startTrilium() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
httpServer.keepAliveTimeout = 120000 * 5;
|
httpServer.keepAliveTimeout = 120000 * 5;
|
||||||
httpServer.listen(usedPort);
|
httpServer.listen(usedPort, usedHost);
|
||||||
httpServer.on('error', onError);
|
httpServer.on('error', onError);
|
||||||
httpServer.on('listening', () => debug('Listening on port' + httpServer.address().port));
|
httpServer.on('listening', () => debug('Listening on port' + httpServer.address().port));
|
||||||
|
|
||||||
@ -108,4 +111,4 @@ function onError(error) {
|
|||||||
default:
|
default:
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user