Trilium搭建同步服务器+域名访问

Trilium搭建同步服务器+域名访问

Trilium搭建同步服务器,并且实现域名访问

文件名:trilium-linux-x64-server-0.45.9.tar.xz

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14

npm -v

6.14.10

node -v

v14.15.3

cd /home/trilium/trilium-linux-x64-server/

npm install

./trilium.sh

使用Ctrl+C退出进程,根据日志进行调试。

此外还需配置config-sample.ini,这里我只修改了端口。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

[General]

# Instance name can be used to distinguish between different instances using backend api.getInstanceName()

instanceName=kkbt

# set to true to allow using Trilium without authentication (makes sense for server build only, desktop build doesn't need password)

noAuthentication=false

# set to true to disable backups (e.g. because of limited space on server)

noBackup=false

# Disable automatically generating desktop icon

# noDesktopIcon=true

[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 a fixed port (changeable with TRILIUM_PORT environment variable)

port=20202

#这里我只修改了端口

# true for TLS/SSL/HTTPS (secure), false for HTTP (unsecure).

https=false

# path to certificate (run "bash bin/generate-cert.sh" to generate self-signed certificate). Relevant only if https=true

certPath=

keyPath=

这时,访问ip+port可以访问Trilium。比如访问192.168.0.1:20202

没有问题之后,把Trilium加入nohup,并让其在后台运行。nohup 为不挂断的运行(即使是ssh退出之后),末尾 & 为后台运行,即运行后终端能够接收任何输入。>Trilium.log 2>&1是将运行log记录到Trilium.log。

1
2

nohup ./trilium.sh >Trilium.log 2>&1 &

如果想要停止进程可以使用

1
2

netstat -anp |grep 20202

查看使用端口20202的进程

da392424318f61c56995c3ec16550bb4.png

使用

1
2

kill -9 23081

结束进程。

可以配合宝塔的网站功能使用域名访问。宝塔版本:7.5.1

注意:使用宝塔需要在安全设置里开放20202端口(或者你使用的端口)。

  1. 宝塔新建网站

  2. 添加反向代理

  3. 修改宝塔反向代理默认配置

图:添加的反向代理

cad0a01a55134877321f24f2ff352e81.png

注意:如果使用默认的反向代理,会出现新建笔记不会自动打开,需要刷新网页之后才能看到。

宝塔网站反向代理配置如下,这份配置来自于Trilium GIthub Wiki

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16

location / {

  proxy_pass http://localhost:20202/;

  proxy_http_version 1.1;

  proxy_set_header Upgrade $http_upgrade;

  proxy_set_header Connection 'upgrade';

  proxy_set_header Host $host;

  proxy_cache_bypass $http_upgrade;

}

访问abc.com即可看到Trilium服务。

d56d9be6bcb4b7e79c7edbe5d0167e27.png

58e6dcfe5889f206d0a8afaaf5061dc4.png

在配置结束后,我关闭了ip访问端口20202的设置。在此之后可以使用域名的同步和访问。

d37906aa516fafbd58cd062ee1dc047a.png