Installation of PouchDB Server as Noteself Sync Hub in Debian 7 (LTS)

Hi there,

I was looking for a modern and fresh version of my personal notebook for quite a while. Noteself with its TiddlyWiki5 integration (or the other way around) seems to be a very hot candidate to me. That's why I took some effort and installed my own instance. Currently I am in the testing phase, but it really looks promising … Let me share my steps for installation of the remote DB on my Debian 7 LTS system.

Installation of PouchDB Server as Noteself Sync Hub

Debian Wheezy is an old distribution but for some reasons I chose the LTS version back when I set up my server. Of course, deploying modern NodeJS on it feels quite awkward, but it did work out quite well with only minor tweaks. I will soon update to either the next LTS distribution or the stable branch or maybe a completely different distribution. So, getting the pouchdb-server daemon running on systemd hosts is not covered here but should also be straightforward.

  1. First I installed nodejs, where I had to choose an old (6.x) version. You probably already have the latest version installed or ready to install from your package repository.
    curl -sL  https://deb.nodesource.com/setup_6.x | bash -
    
  2. Installation of pouchdb-server
    npm install -g pouchdb-server
    

Create a PouchDB Server daemon

I wrote the init script and saved it under /etc/init.d/pouchdb-serverd You can find out about the DAEMONOPTS which I use. I created the directories and the config.json file. I choose the sqlite database backend for pouchDB, but that is just personal preference. Finally, start the server ( service pouchdb-serverd start) and check if everything works as it should.

Security & Deployment

I may want to use my Notebook from work and from home. As some basic considerations, I configured iptables to only allow IP address ranges from my ISP and company proxies access the port. Next, I setup a stunnel to enable encrypted transport layer SSL.

Setup of stunnel

  1. Install the package
    apt-get install stunnel4
    
  2. Generate a self-signed certificate
    openssl genrsa -out key.pem 2048
    openssl req -new -x509 -key key.pem -out cert.pem
    cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
    
  3. Configure stunnel in /etc/stunnel/stunnel.conf for usage with pouchdb-server
    [pouchdb-server]
    accept = 6984
    connect = 127.0.0.1:5984
    cert = /etc/stunnel/stunnel.pem
    
  4. Again, (re)start stunnel and check if the PouchDB server is working on your SSL enabled port
    service restart stunnel
    curl <hostname>:6984
    

Use Noteself with Sync

Disable the Admin Party at your new&fresh PouchDB server in Fauxton, create a new admin and user account (the user for the Noteself DB needs to be in the admins group). Download the noteself.html file, configure the CouchDB server settings for your host and—voilá!— you have sync of your new digital notebook companion in all your browsers, at work, at home, mobile…. Just remember to restart your browser with a fresh, empty noteself instance.

Just a last thing, the Noteself developer, Danielo Rodríguez Rivero, hints to Noteself's Beta stage. I am also not sure about the production readiness of PouchDB Server. So, having no long term experience yet, I keep fingers crossed for stability and also future TiddlyWiki integration. Good luck !

— Martin

3 Likes

Thank you very much for taking the time of helping others follow the same path as you.

Regards