Commit 566a5ce4ec

566a5ce4ec810bf5f4a941fb0c27fa215a0ad458

parent: e2a27f7047

Unsigned

cmc <hello@cleberg.net> · 2024-02-21 22:21 UTC

add otterwiki post

Layout: unified · split

content/blog/2024-02-21-self-hosting-otter-wiki.md added +135
@@ -0,0 +1,135 @@
1+++
2date = 2024-02-21
3title = "Self-Hosting An Otter Wiki"
4description = "Learn how to easily self-host An Otter Wiki."
5+++
6
7## An Otter Wiki
8
9[An Otter Wiki](https://otterwiki.com/) is an easy to use wiki software that
10takes almost no effort to set up 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```sh
23mkdir ~/otterwiki
24```
25
26Next, create the `docker-compose.yml` file to define the container's parameters.
27
28```sh
29nano ~/otterwiki/docker-compose.yml
30```
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```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```
48
49Once the file is saved and closed, you can launch the container.
50
51```sh
52cd ~/otterwiki
53sudo docker-compose up -d
54```
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```sh
65sudo nano /etc/nginx/sites-available/wiki
66```
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`
71server block to `80` to serve the app without SSL.
72
73```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```
108
109Save and close the configuration file. On Nginx, we need to symlink the file to
110enable it.
111
112```sh
113sudo ln -s /etc/nginx/sites-available/wiki /etc/nginx/sites-enabled/wiki
114```
115
116Once enabled, restart the Nginx server to start serving the app externally.
117
118```sh
119sudo systemctl restart nginx.service
120```
121
122## Screenshots
123
124In the screenshot below, you can see the initial launch screen for An Otter
125Wiki. Start by creating your admin account and configure the app as necessary.
126
127![An Otter Wiki - Initial Screen](https://img.cleberg.net/blog/20240221-otterwiki/otterwiki.png)
128
129You can also see the default editing screen for creating and editing pages. It's
130as easy as typing Markdown and hitting the save button.
131
132![An Otter Wiki - Editing Screen](https://img.cleberg.net/blog/20240221-otterwiki/otterwiki-edit.png)
133
134Overall, I like An Otter Wiki and will be looking forward to seeing how much use
135I get out of it going forward.