All Pages > Services > Distributed wiki
this page is outdated and need update
The idea is to deploy mirrors across dn42 using anycast addressing (BGP), thus providing redundancy, load-balancing and improved access times to the wiki. Sites are powered by gollum which has no native SSL support, so Nginx acts as a reverse proxy and handles the encryption. The local webserver is monitored with a simple shell script working in conjunction with ExaBGP, announcing/withdrawing the assigned route if the service is up/down.
Prerequisites
Stable 24/7 connection to dn42.
Stable host machine, present in dn42.
Solid networking/sysadmin skills (to keep the system as a whole stable).
In contrast with the general spirit in dn42, this service should NOT be deployed by unskilled members for the purpose of learning and exploring - since it is the primary source of information related to the project, it should not be used as a playground.
Software:
It's recommended to use a debian distro on the host machine, where most of the above software can be installed using package manager(s) with ease. On some distros (RHEL based for example) it might not be an easy task.
Network
- Install wiki anycast IP addresses
172.23.0.80/32
andfd42:d42:d42:80::1/64
on the system - Assign a unicast IP address to be used by Nginx
- Establish connectivity to the dn42 network
Data replication
Site files are stored in a local DVCS repository (Git) on each node and replicated through a central server hosted by XUU-DN42. Since gollum is built on top of Git, it is not overly complicated to keep the local site in sync with others, each site only triggers periodic pulls/pushes from/to the Git server.
Setup the repo
Clone the dn42 wiki repo:
git clone git@git.dn42.dev:wiki/wiki.git <path>
Contact XUU-DN42 and ask for write access to the repo
Setup cron for periodic pull/push jobs for the repo (simple example):
- wiki-sync.sh:
#!/bin/bash
WIKI_PATH=<repo GIT=/usr/bin/git
- Cron entry:
*/10 * * * * <path>/wiki-sync.sh &> /dev/null
Running in 10 minute intervals is reasonable, if you choose to change this, please keep it in the range from 5 to 15 minutes.
gollum
Install gollum
Start two gollum instances, read-only and read/write on
127.0.0.1
:Read/write (SSL only):
RACK_ENV=production gollum --css --host 127.0.0.1 --port 4568 Wait for a reply and then sign the certificate: A custom header Extract base64 encoded SPKI fingerprint from private key openssl rsa -in wiki.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64 ``` Configure Nginx to send the fingerprint in header (SSL block): add_header Public-Key-Pins pin-sha256=" Read more about this here. The proxy should accept the following domain names: Nginx should listen on a unicast address as well, so your site can be reached exclusively. Assign an IP address for the occasion and send it to XUU-DN42 including your AS The prefix AS-PATH should show the announcement is originating from your AS. After peering ExaBGP to the nearest speaker(s), check if the prefix is routing properly inside your network. Try not to blackhole the passing traffic (e.g. no static routes to Watchdog runs in an infinite loop, sending the appropriate commands to stdout. ExaBGP attaches to the process' stdout and listens for instructions. Watchdog sends either a route announce or widthdraw. Run Normally SIGUSR1 to the exabgp process triggers a configuration update, but at occasion the process might need to be restarted - since its gracefull shutdown can be glitchy , this might be a bit difficult. Sending SIGKILL to the child(ren) and immediately after, the parent, does the job (quick-and-dirty).Read-only:
RACK_ENV=production gollum --css --host 127.0.0.1 --port 4567 --no-edit Set `<path>` to the location where wiki Git repo was cloned.
Nginx reverse proxy
SSL
as
like as64737-ca.wiki.dn42
./ca.dn42 tls-sign wiki.dn42 MIC92-MNT
Header
Site identification
X-SiteID
identifies the site you're connecting to:add_header X-SiteID '<AS>-<ISO country code>';
as
like as64737
Enabling HPKP
wiki.key
:<primary>
- the fingerprint extracted from wiki.key
<backup>
- the CA fingerprint: of00RDinhPeVRNnXm1jXQDagktOL75qQo1pT+xc7VIE=
Domains
<aut-num>
and the country code <CC>
where your site is located. A forward DNS record will be created, pointing to the unicast IP address:<aut-num>
-<CC>``(-<UID>)
.wiki.dn42Config example
.2 TLSv1.1 TLSv1;
shared:SSL:2m;
ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;
on;
wiki { server ; }
server {
internal.dn42 wiki.dn42 as<aut-num>-<cc>.wiki.dn42;
default;
[fd42:d42:d42:80::1]:80 default;
<unicast ipv4> 80;
[<unicast ipv6>]:80;
X-SiteID '<aut-num>-<cc>';
location / {
;
}
}
wikirw { server ; }
server {
internal.dn42 wiki.dn42 as<aut-num>-<cc>.wiki.dn42;
ssl default;
[fd42:d42:d42:80::1]:443 ssl default;
<unicast ipv4> 443 ssl;
[<unicast ipv6>]:443 ssl;
on;
<path>/ssl.crt;
<path>/ssl.key;
strict-transport-security "max-age=5184000; includeSubDomains";
Public-Key-Pins 'pin-sha256="<primary-pin>";pin-sha256="<backup-pin>"; max-age=5184000; includeSubDomains';
X-SiteID '<aut-num>-<cc>';
location / {
;
}
}
TLSv1
ExaBGP
Announcing
172.23.0.80/32
). Test the whole thing by shutting down nginx/gollum and watch what happens.Configuration
-watchdog {
<peer1> {
x.x.x.x;
<source-address>;
<ownas>;
<peeras>;
}
{
;
;
123456;
123456;
}
fd42:4992:6a6d::1 {
;
fd42:4992:6a6d::2;
123456;
123456;
}
watch-gollum {
<path>/gollum-watchdog.sh;
}
}
gollum
Watchdog script
gollum-watchdog.sh
in a shell first to validate it's working:#!/bin/bash
CURL=curl
## url's to check (all listed must be alive to send announce)
URL=("http://172.23.0.80" "https://172.23.0.80" "http://[fd42:d42:d42:80::1]" "https://[fd42:d42:d42:80::1]")
ROUTE='172.23.0.80/32'
## the anycast v6 route (/64 due to prefix size limits)
ROUTE6='fd42:d42:d42:80::/64'
## the next-hop we'll be advertising to neighbor(s)
NEXTHOP='<source-address>'
NEXTHOP6='<source-address-v6>'
## regex match this keyword against HTTP response from curl
VALIDATE_KEYWORD='gollum'
INTERVAL=60
###########################
RUN_STATE=0
while [; do
if [; then
&& {
RUN_STATE=1
}
else
|| {
RUN_STATE=0
}
fi
done
Run
USAGE: /etc/exabgp/run.sh [start|stop|restart]
#!/bin/bash
PID_FILE=/var/run/exaBGP/exabgp_PID
######################################
EXABGP=<path>/sbin/exabgp
EXA_LOG=/var/log/exabgp.log
CONF=/etc/exabgp/exabgp.conf