Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

obsidian-livesync 是 obsidian 的一个community plugin,使用需要 self-host 一个 CouchDB server。本文的 CouchDB server 是在 VPS 上以 docker-compose 方式安装的,使用 nginx 作为 reverse proxy

偶然看到两篇和 obsidian-livesync 插件有关的文章,写得很详细:

安装设置 CouchDB server

文件结构:

obsidian-livesync
  ├── docker-compose.yml
  ├── data (folder)
  └── local.ini

写入 docker-compose.yml

version: "3"
services:
  couchdb:
    image: couchdb
    container_name: obsidian-livesync
    environment:
      - COUCHDB_USER=admin
      - COUCHDB_PASSWORD=<your_password>
    volumes:
      - ./data:/opt/couchdb/data
      - ./local.ini:/opt/couchdb/etc/local.ini
    ports:
      - 5984:5984
    restart: unless-stopped

写入 local.ini

[couchdb]
single_node=true
max_document_size = 50000000

[chttpd]
require_valid_user = true
max_http_request_size = 4294967296

[chttpd_auth]
require_valid_user = true
authentication_redirect = /_utils/session.html

[httpd]
WWW-Authenticate = Basic realm="couchdb"
enable_cors = true

[cors]
origins = app://obsidian.md,capacitor://localhost,http://localhost
credentials = true
headers = accept, authorization, content-type, origin, referer
methods = GET, PUT, POST, HEAD, DELETE
max_age = 3600

docker compose up -d 上线容器

设置 nginx

<your_domain> 修改成你准备的域名,配置文件完全按照了 nginx couchdb reverse proxy - Lloyd Rochester’s Geek Blog 写的内容

server {
    server_name <your_domain>;
    listen 80;
    listen [::]:80;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;

    gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css application/json;

    server_name <your_domain>;

    ssl_certificate /etc/letsencrypt/live/<your_domain>/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/<your_domain>/privkey.pem; # managed by Certbot

    location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
       expires 10d;
    }

    # reverse proxy for couchdb
    location / {
        proxy_pass http://127.0.0.1:5984/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

设置 obsidian 插件

只能同时有一个同步插件,不能和官方同步服务一起用,要不容易数据问题

打开 obsidian,搜索 community plugins,安装 Self-hosted LiveSync,然后手动填写 Remote Database configuration 选项卡,接着在 Sync Setiings 选项卡里选择自己满意的同步频率

Obsidian 设置 详细介绍了如何设置 obsidian

参考内容

评论