Docker Compose
Below is the docker compose file just to get CouchDB up and running:
version: "3.8"
services:
couchdb-obsidian-livesync:
container_name: obsidian-livesync #shortened name
image: couchdb:3.3.3
environment:
- PUID=99
- PGID=100
- UMASK=0022
- TZ=Asia/Ho_Chi_Minh
- COUCHDB_USER=obsidian_user # optionally change me
- COUCHDB_PASSWORD=obsidian_password # definitely change me
volumes:
- ./data:/opt/couchdb/data
- ./etc/local.d:/opt/couchdb/etc/local.d
- ./log:/opt/couchdb/var/log/couchdb # Added log volume
ports:
- "5984:5984"
restart: unless-stopped
labels:
- net.unraid.docker.webui=http://[IP]:[PORT:5984]/_utils # This might need to be manually adjusted for the web UI
- net.unraid.docker.icon=https://couchdb.apache.org/image/[email protected]
- net.unraid.docker.shell=bash
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:5984/_up"] # Healthcheck for CouchDB
interval: 30s
timeout: 10s
retries: 3
start_period: 5s
CouchDB – Initial Configuration
-
Go to the CouchDB admin page by going here: http://10.10.10.13:5984/_utils make sure to use your server’s IP address.
-
Login using the credentials you set in the Docker compose file.
-
Click on the
<->
icon on the top left, it will expand the menu from simple icons to icons with text which will make following this guide easier. -
Click on
Setup
on the left menu. -
Click on
Configure as Single Node
and enter the same credentials from the Docker compose file into theSpecify your Admin credentials
fields. -
Leave everything else the same and click
Configure Node
.
CouchDB – Verify Installation
-
Let’s verify the CouchDB installation by clicking
Verify
on the left menu. -
Click
Verify Installation
and if everything is good, a popup banner should popup sayingSuccess! Your CouchDB installation is working. Time to Relax.
along with 6 check marks next to each item in the table.
CouchDB – Create Database
-
Click on the
Databases
on the left menu. -
Click on
Create Database
on the top right. -
Under
Database Name
enterobsidiandb
, or whatever you like. Advice: if you intend to use this setup for multiple users, each user will need their own database, so I recommend naming the database to include the user’s first name like:obsidiandb_john
orobsidiandb_jane
just to make it easier in the future. -
Under
Partitioning
selectNon-partitioned - recommended for most workloads
. Once the database is created, you should be redirected to the new database’s config page. You don’t have to do anything here.
CouchDB – Configuration
-
Click on
Configuration
on the left main menu. The following 9 config entries are what the script was intended to do automatically but I wanted to do it manually. Click on+ Add Option
on the top right for each entry: -
Section:
chttpd
Name:require_valid_user
Value:true
-
Section:
chttpd_auth
Name:require_valid_user
Value:true
-
Section:
httpd
Name:WWW-Authenticate
Value:Basic realm="couchdb"
-
Section:
httpd
Name:enable_cors
Value:true
-
Section:
chttpd
Name:enable_cors
Value:true
-
Section:
chttpd
Name:max_http_request_size
Value:4294967296
-
Section:
couchdb
Name:max_document_size
Value:50000000
-
Section:
cors
Name:credentials
Value:true
-
Section:
cors
Name:origins
Value: `app://obsidian.md,capacitor://localhost,http://localhost
Obsidian – Windows 11 Client
-
Download and install the Windows 11 Obsidian client from here.
-
Once installed, open Obsidian.
-
Next to
Create new vault
click theCreate
button next. -
In the
Vault name
field, name your Vault whatever you like, I simply named mineVault
. You can think of a vault as a "master folder" that contains all your folders and notes. Some users have different vaults for different aspects of their lives, such asWork
orPersonal
but I keep everything under one vault for ease of use. -
Next setting is
Location
, clickBrowse
. This is where your vault will be locally saved. I created anObsidian
folder in theDocuments
folder but you can put it anywhere you like. -
Click
Create
and Obsidian should open up to your newly created vault with 3 window panes. Next step is to setup the LiveSync plugin.
Obsidian – LiveSync Plugin
-
Click on
options
button (sprocket icon) on the bottom left area. -
Click
Community plugins
and click on theTurn on community plugins
button after reading the risk disclosure. -
Next to
Community plugins
click on theBrowse
button. -
Search for
Self-hosted LiveSync
. -
Only 1 plugin should show up and that’s the one by
voratamoroz
, click on it. -
Click the
Install
button and let it install. -
Click the
Enable
button. -
Click
Open setting dialog
button. -
Click
Options
button. -
Under
Settings for Self-hosted LiveSync.
you should see a row of 8 buttons, click on the 4th button with the 🛰️ satellite icon. -
This is where we will enter the self-hosted CouchDB details. Next to
Remote Type
make sureCouchDB
is selected from the drop down menu. -
In the
URI
field type http://10.10.10.13:5984 make sure to change to your server IP and port. (Open the container online with HAProxy) -
In the
Username
field typeosidian_user
or whatever you used in the docker compose. -
Same for
Password
field. -
In the
Database name
field typeobsidiandb
or whatever you named your database earlier in CouchDB. -
Click the
Test
button to test the connection to the CouchDB database. Assuming everything is working properly a text popup should sayConnected to obsidiandb successfully
. -
Click the
Check
button to confirm the database was configured properly, there should be a purple checkmark next to each line item. If not, there should be aFix
button next to the item that you can click for it to either create or correct for you, but I prefer to manually do it myself. -
Assuming everything is good up to this point, click the
Apply
button next toApply Settings
. -
Optional but recommended: scroll down to the
End-to-end encryption
and toggle it on and set a passphrase. Please remember this passphrase as all your other devices must have matching passphrases for it to be able to decrypt your notes. Click the red buttonJust apply
. -
On the top menu, under
Settings for Self-hosted LiveSync.
you should see a row of 8 buttons, click on the 5th button with the 🔄 refresh icon. -
Next to
Sync mode
selectLiveSync
from the drop down menu. -
You can close the
settings
windows out, on the top right of the notes you should seeSync: zZz
which means everything is working properly and the sync is in standby mode until you start typing something. -
Repeat the above instructions for all other devices.
Reverse Proxy
I highly recommend putting this behind at least a reverse proxy, I use Nginx Proxy Manager in conjunction with Cloudflare Tunnels. You will definitely need to if you plan on using mobile devices as they require HTTPS.