Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Public Library local setup (no docker).md

view this document here:!provider=gist&gistId=7547779&



SSH tunneling

Calibre plugin [let's share books] establishes SSH tunnel as a user tunnel with SSH server through port 722 without authorization.

That allows local Calibre content server to get proxied through SSH tunnel and Nginx so Calibre content server can get its own public URL (i.e. Local Calibre library is then accessible from the world to which Nginx is exposed. In production setup that's, in development setup that's usually only developer's laptop.

Webapp unifying all proxied libraries

Calibre plugin [let's share books] collects all metadata about the books (in current Calibre library) and send it to webapp which then unifies all libraries into unique interface.

Webapp shows all the books from libraries and enables search through all of them.


Adding user 'tunnel'

sudo useradd -m -g users -s /bin/bash tunnel

then remove character ! in /etc/shadow in line which looks like this:


it should then look like this:



make new configuration file sshd_config_tunnel in directory /etc/ssh/:

UsePAM no
 AllowUsers tunnel
 Port 722

Match User tunnel
 ForceCommand /bin/echo do-not-send-commands
 AllowTcpForwarding yes
 PasswordAuthentication yes
 PermitEmptyPasswords yes`

run ssh daemon with that configuration:

sudo /usr/bin/sshd -D -f /etc/ssh/sshd_config_tunnel


local domain name dokr is used because of original development setup with it could be any name one prefers. this document covers setup without docker. everything is running in the same operating system session. if you use some other name check out the code and replace dokr instances accordingly

if you use dnsmasq add line to /etc/dnsmasq.conf:


if you use NetworkManager add line to /etc/NetworkManager/dnsmasq.d/local:


restart dnsmasq daemon or NetworkManager.


make new configutation lsb file in /etc/nginx/sites-available:

server {
            server_name   "~^www(?<port>\d{4,5}).web.dokr"
            listen 80;
            location / {
            proxy_set_header  X-Real-IP  $remote_addr;
                proxy_set_header  Host $host;

if you use /etc/nginx/sites-available for you configuration files you should add symlink to /etc/nginx/sites-enabled:

cd /etc/nginx/sites-enabled
sudo ln ../sites-available/lsb lsb

also check if you have this line in /etc/nginx.conf:

http {
include /etc/sites-enabled/*;

run nginx as you run it on your linux distribution. i.e.:

sudo systemctl start nginx


sudo service nginx start

add shell script to /usr/local/bin/:


ss -4el|grep uid:$1|cut -d ":" -f 2|cut -d " " -f 1

make it executable:

sudo chmod +x /usr/local/bin/


  2. git clone
  3. pip install cherrypy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment