cmc/cleberg.net
My personal web garden & blog.
clone: git clone https://gitbay.org/cmc/cleberg.net.git
main: content/blog/2024-02-21-self-hosting-otter-wiki.org · raw
1#+date: [2024-02-21 Wed 00:00:00]
2#+title: Self-Hosting Guide: Otter Wiki
3#+description: How to self-host Otter Wiki with Docker Compose and Nginx.
4#+slug: self-hosting-otter-wiki
5#+filetags: :linux:self-hosting:
6
7* An Otter Wiki
8
9[[https://otterwiki.com/][An Otter Wiki]] is an easy to use wiki software that takes almost no effort to set
10up and maintain.
11
12* Installation
13
14To install An Otter Wiki, I'm going to use Docker Compose to create the
15container and then use Nginx as a reverse proxy to allow external access via a
16subdomain I own.
17
18** Docker Compose
19
20Start by creating a directory for the container's files.
21
22#+begin_src sh
23mkdir ~/otterwiki
24#+end_src
25
26Next, create the =docker-compose.yml= file to define the container's parameters.
27
28#+begin_src sh
29nano ~/otterwiki/docker-compose.yml
30#+end_src
31
32Within the file, paste the following content. You can read the project's
33documentation if you want to further override or customize the container.
34
35#+begin_src conf
36version: '3'
37services:
38 otterwiki:
39 image: redimp/otterwiki:2
40 restart: unless-stopped
41 # Internal port must be assigned to port 80
42 # External port can be customized
43 ports:
44 - 8337:80
45 volumes:
46 - ./app-data:/app-data
47#+end_src
48
49Once the file is saved and closed, you can launch the container.
50
51#+begin_src sh
52cd ~/otterwiki
53sudo docker-compose up -d
54#+end_src
55
56The container is now available at =localhost:8337=. Next, we will use Nginx to
57serve this app externally.
58
59** Nginx
60
61To access the app externally, let's set up a reverse proxy. I'll start by
62creating the Nginx configuration file for my wiki.
63
64#+begin_src sh
65sudo nano /etc/nginx/sites-available/wiki
66#+end_src
67
68Within the file, I have saved the following content. This assumes you already
69have a TLS/SSL cert to use with this subdomain. If not, simply remove the
70=ssl_*= variables, remove the =80= server block, and change the =443= server
71block to =80= to serve the app without SSL.
72
73#+begin_src conf
74server {
75 if ($host ~ ^[^.]+\.example\.com$) {
76 return 301 https://$host$request_uri;
77 }
78
79 listen [::]:80;
80 listen 80;
81 server_name wiki.example.com;
82 return 404;
83}
84
85server {
86 listen [::]:443 ssl http2;
87 listen 443 ssl http2;
88 server_name wiki.example.com;
89 access_log /var/log/nginx/wiki.access.log;
90 error_log /var/log/nginx/wiki.error.log;
91
92 ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
93 ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
94 include /etc/letsencrypt/options-ssl-nginx.conf;
95 ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
96
97 location / {
98 set $upstream_wiki http://127.0.0.1:8337;
99 proxy_pass $upstream_wiki;
100
101 proxy_set_header Host $http_host;
102 proxy_set_header X-Real-IP $remote_addr;
103 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
104 proxy_set_header X-Forwarded-Host $http_host;
105 }
106}
107#+end_src
108
109Save and close the configuration file. On Nginx, we need to symlink the file to
110enable it.
111
112#+begin_src sh
113sudo ln -s /etc/nginx/sites-available/wiki /etc/nginx/sites-enabled/wiki
114#+end_src
115
116Once enabled, restart the Nginx server to start serving the app externally.
117
118#+begin_src sh
119sudo systemctl restart nginx.service
120#+end_src