Skip to main content
Plugin: LiveSync

Plugin: LiveSync #

Self-host without caddy #

Docker & DB setup #

File tree:

user@vps:~/DOCKERS/obsidian-livesync$ tree -L 2
.
├── conf
│   └── local.ini
└── docker-compose.yml

Docker-compose file: (altered from original)

After setting up the remote machine, before taking to the Obsidian plugin, remember to add admin user in CouchDB, and delete user1!

Create new admin with: Your AccountCreate Server Admin

Delete old admin with: Configurationadminsuser1delete

docker-compose.yml yaml
version: "3.7"
# convenient compose file for Self-hosted LiveSync.
# Initial Author: @arminus
# Modified      : @vrtmrz

services:
    couchserver:
        image: couchdb:3.1.2
        ports:
            - "5984:5984"
        environment:
            - COUCHDB_USER=user1
            - COUCHDB_PASSWORD=password1
        volumes:
            # The files' owner will be id:5984 when you launch the image.
            # Because CouchDB writes on-the-fly configurations into local.ini.
            # So when you want to perform git pull or change something, you have to change owners back.
            - ./data/couchdb:/opt/couchdb/data
            - ./conf/local.ini:/opt/couchdb/etc/local.ini
            - ./local.d:/opt/couchdb/etc/local.d
        restart: always

CouchDB ini file: (altered from original)

local.ini sh
[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
timeout = 600

[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

Nginx setup #

Nginx config:

/etc/nginx/sites-available/obsidian_livesync.conf sh
server {
    server_name obslivesync.your.domain;

    listen 443 ssl;
    ssl_certificate /ADMIN/https-certs/all.your.domain.public.pem;
    ssl_certificate_key /ADMIN/https-certs/all.your.domain.private.key;

  location / {
    proxy_pass http://localhost:5984/;
    
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
    
    proxy_connect_timeout 60s;
    proxy_send_timeout 60s;
    proxy_read_timeout 60s;
    
    proxy_buffering on;
    proxy_buffer_size 4k;
    proxy_buffers 8 4k;
    proxy_busy_buffers_size 8k;
    
    proxy_redirect off;
    proxy_cache_bypass $http_upgrade;
  }
}

Usage:

sudo vim /etc/nginx/sites-available/obsidian_livesync.conf
sudo ln -s /etc/nginx/sites-available/obsidian_livesync.conf /etc/nginx/sites-enabled/obsidian_livesync.conf