Post

Obsidian LiveSync

Deploy locally

  1. Prepare
1
2
3
# Creating the save data & configuration directories.
mkdir couchdb-data
mkdir couchdb-etc
  1. Create a compose.yml file with the following added to it

without proxy

1
2
3
4
5
6
7
8
9
10
11
12
13
services:
  couchdb:
    image: couchdb:latest
    container_name: couchdb-for-ols
    environment:
      - COUCHDB_USER=<INSERT USERNAME HERE> #Please change as you like.
      - COUCHDB_PASSWORD=<INSERT PASSWORD HERE> #Please change as you like.
    volumes:
      - ./couchdb-data:/opt/couchdb/data
      - ./couchdb-etc:/opt/couchdb/etc/local.d
    ports:
      - 5984:5984
    restart: unless-stopped

with Traefik

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
41
services:
  couchdb:
    image: couchdb:latest
    container_name: obsidian-livesync
    environment:
      - COUCHDB_USER=username
      - COUCHDB_PASSWORD=password
    volumes:
      - ./data:/opt/couchdb/data
      - ./local.ini:/opt/couchdb/etc/local.ini
    # Ports not needed when already passed to Traefik
    #ports:
    #  - 5984:5984
    restart: unless-stopped
    networks:
      - proxy
    labels:
      - "traefik.enable=true"
      # The Traefik Network
      - "traefik.docker.network=proxy"
      # Don't forget to replace 'obsidian-livesync.example.org' with your own domain
      - "traefik.http.routers.obsidian-livesync.rule=Host(`obsidian-livesync.example.org`)"
      # The 'websecure' entryPoint is basically your HTTPS entrypoint. Check the next code snippet if you are encountering problems only; you probably have a working traefik configuration if this is not your first container you are reverse proxying.
      - "traefik.http.routers.obsidian-livesync.entrypoints=websecure"
      - "traefik.http.routers.obsidian-livesync.service=obsidian-livesync"
      - "traefik.http.services.obsidian-livesync.loadbalancer.server.port=5984"
      - "traefik.http.routers.obsidian-livesync.tls=true"
      # Replace the string 'letsencrypt' with your own certificate resolver
      - "traefik.http.routers.obsidian-livesync.tls.certresolver=letsencrypt"
      - "traefik.http.routers.obsidian-livesync.middlewares=obsidiancors"
      # The part needed for CORS to work on Traefik 2.x starts here
      - "traefik.http.middlewares.obsidiancors.headers.accesscontrolallowmethods=GET,PUT,POST,HEAD,DELETE"
      - "traefik.http.middlewares.obsidiancors.headers.accesscontrolallowheaders=accept,authorization,content-type,origin,referer"
      - "traefik.http.middlewares.obsidiancors.headers.accesscontrolalloworiginlist=app://obsidian.md,capacitor://localhost,http://localhost"
      - "traefik.http.middlewares.obsidiancors.headers.accesscontrolmaxage=3600"
      - "traefik.http.middlewares.obsidiancors.headers.addvaryheader=true"
      - "traefik.http.middlewares.obsidiancors.headers.accessControlAllowCredentials=true"

networks:
  proxy:
    external: true
  1. Run the Docker Compose file to boot check
1
docker compose up -d

Go to CouchDB admin page

  • Go to your server ip eg. http://192.168.1.0:5984/_utils, login with your credentials created in compose file. /assets/img/obd-01.png

  • You will see your db in CouchDB
  • Open Obsidian apps and browse the LiveSync plugin /assets/img/obd-02.png

  • Click Option and setup your connection.
  • Server URI, Username, Password, Database Name /assets/img/obd-03.png

  • Test Database Connection, Encryption /assets/img/obd-04.png

  • Synchronization Method i. Change Live Sync method /assets/img/obd-05.png

Install Obsidian on mobile

  • Create a new vault and install the LiveSync plugin and configure the connection. The same setting in desktop side, then click Fetch button Fetch Settings. /assets/img/obd-06.png

Done! It will sync the notes in live.

ref link: https://github.com/vrtmrz/obsidian-livesync

This post is licensed under CC BY 4.0 by the author.