services/Distributed-Wiki-New.md
... ...
@@ -1,19 +1,139 @@
1
-## Anycast Wiki Mirrors
1
+## Introduction
2 2
3
-These instances are part of the anycast network for [wiki.dn42](https://wiki.dn42/) and run the new wiki software, `dn42-wiki-go`, which replaces the legacy `Gollum`.
3
+[dn42-wiki-go](https://github.com/iedon/dn42-wiki-go) is a lightweight, Git-backed wiki engine designed for DN42. It is based on [wiki-ng](https://git.dn42.dev/wiki/wiki-ng), aims to replace the old Gollum-based DN42 distributed wiki.
4 4
5
-| Node / Region | URL | ASN |
6
-| ----------------------- | ------------------------------------------- | ----------- |
7
-| iedon.dn42 114 (US-LAX) | [https://wiki-114.iedon.dn42/](https://wiki-114.iedon.dn42/) | 4242422189 |
8
-| iedon.dn42 116 (JP-TYO) | [https://wiki-116.iedon.dn42/](https://wiki-116.iedon.dn42/) | 4242422189 |
9
-| iedon.dn42 117 (US-SJC) | [https://wiki-117.iedon.dn42/](https://wiki-117.iedon.dn42/) | 4242422189 |
10
-| iedon.dn42 119 (SG-SIN) | [https://wiki-119.iedon.dn42/](https://wiki-119.iedon.dn42/) | 4242422189 |
11
-| iedon.dn42 120 (HK-HKG) | [https://wiki-120.iedon.dn42/](https://wiki-120.iedon.dn42/) | 4242422189 |
12
-| iedon.dn42 121 (CN-CZX) | [https://wiki-121.iedon.dn42/](https://wiki-121.iedon.dn42/) | 4242422189 |
13
-| iedon.dn42 122 (UK-LON) | [https://wiki-122.iedon.dn42/](https://wiki-122.iedon.dn42/) | 4242422189 |
14
-| iedon.dn42 124 (US-NYC) | [https://wiki-124.iedon.dn42/](https://wiki-124.iedon.dn42/) | 4242422189 |
15
-| iedon.dn42 125 (DE-FRA) | [https://wiki-125.iedon.dn42/](https://wiki-125.iedon.dn42/) | 4242422189 |
5
+It can serve pages live through its built-in Go HTTP server or generate a fully static HTML export for external hosting. All content is stored in a Git repository, making it easy to replicate across nodes or run in disconnected environments.
16 6
17
-## Deploying dn42-wiki-go
7
+## Operating Modes
8
+
9
+You can run `dn42-wiki-go` in three different ways:
10
+
11
+1. **Run static build once then exit (`--build` or `live=false`)**
12
+ The App renders all Markdown files into HTML under outputDir and exits.
13
+ Best for setups where your own cron job handles Git sync and file publishing.
14
+
15
+2. **Live mode without reverse proxy (`live=true`)**
16
+ The built-in HTTP server directly serves pages, assets, and APIs.
17
+ Suitable for simple deployments.
18
+
19
+3. **Live mode behind a reverse proxy**
20
+ The reverse proxy (nginx, Caddy, HAProxy, etc.) serves the generated files, and only API endpoints are forwarded to the App.
21
+ See `config.example.json` for example configs and `nginx-vhost.conf` for a reverse-proxy reference.
22
+
23
+ **Recommended for production and anycast nodes**.
24
+
25
+## Features
26
+
27
+- Live mode with automatic Markdown rendering and scheduled Git pull/push.
28
+- Static mode for fully pre-built HTML exports.
29
+- Optional in-browser editor with commit metadata (author, message prefix, remote IP).
30
+- Webhook endpoints for remote pull/push triggers and optional polling integration(see `dn42notifyd`).
31
+- Themeable templates and bundled UI assets.
32
+- Designed for distributed, multi-node and anycast environments.
33
+
34
+## Quick Start
35
+
36
+Pre-built binaries are available in the [GitHub releases](https://github.com/iedon/dn42-wiki-go/releases).
37
+
38
+Please do not forget to clone the repository to copy `config.example.json` and the `template` folder. They should be put together in the same production directory.
39
+
40
+### Manual Build
41
+
42
+1. Install Go 1.24+ and ensure the git executable is available in PATH.
43
+2. Copy the example config:
44
+ cp config.example.json config.json
45
+ Then edit the settings you need.
46
+3. Build for your platform (example: Linux amd64):
47
+ ```bash
48
+ export GOOS=linux
49
+ export GOARCH=amd64
50
+ ./build.sh
51
+ ```
52
+
53
+## Webhook Endpoints
54
+
55
+When `webhook.enabled` = true, the server exposes:
56
+
57
+- GET | POST /api/webhook/pull
58
+ Runs git pull and rebuilds the cached HTML.
59
+
60
+- GET | POST /api/webhook/push
61
+ Pushes local commits to the remote.
62
+
63
+If `webhook.secret` is set, requests must include an Authorization header that matches the secret.
64
+
65
+### Polling Integration
66
+
67
+When `webhook.polling.enabled` = true, the server registers with a remote notify service and triggers `/api/webhook/pull` whenever a refresh completes.
68
+
69
+This is compatible with `dn42notifyd` and similar tools.
70
+
71
+## Configuration Reference
72
+
73
+All settings are provided through a JSON file. Below is a concise reference of all options.
74
+
75
+### Runtime
76
+
77
+- `live` *(bool, default `false`)*:
78
+ true -> run HTTP server and render on demand.
79
+ false -> render once to outputDir and exit.
80
+
81
+- `editable` *(bool, default `false`)*:
82
+ Enables in-browser editing and write operations.
83
+
84
+- `listen` *(string, default `":8080"`)*:
85
+ TCP address (host:port) or UNIX socket (unix:/path).
86
+
87
+ Advanced: See example systemd files `dn42-wiki-go.socket` and `dn42-wiki-go.service` in the repository.
88
+
89
+- `baseUrl` *(string, optional)*:
90
+ URL prefix when hosting under a subdirectory.
91
+
92
+- `siteName` *(string, default `"DN42 Wiki Go"`)*:
93
+ Display name of the wiki.
94
+
95
+### Git
96
+- `git.binPath` *(string, default `git`)*: Path to the Git executable.
97
+- `git.remote` *(string, default empty)*: Remote URL. Leave empty for standalone/local repositories.
98
+- `git.localDirectory` *(string, default `./repo`)*: Directory where the wiki repository is cloned or initialised.
99
+- `git.pullIntervalSec` *(int, default `300`)*: Seconds between background `git pull` operations in live mode. Disabled if no remote is set.
100
+- `git.author` *(string, default `"Anonymous <anonymous@localhost>"`)*: Author string used for commits generated by the application, unless a custom author is provided per request.
101
+- `git.commitMessagePrefix` *(string, default empty)*: Optional prefix prepended verbatim to commit messages supplied by users.
102
+- `git.commitMessageAppendRemoteAddr` *(string, default empty)*: Optional suffix appended when a request carries a remote address. If the value contains `%s` it is treated as a `fmt` format string; otherwise it is concatenated.
103
+
104
+### Webhook
105
+- `webhook.enabled` *(bool, default `false`)*: Expose webhook endpoints on the main HTTP server.
106
+- `webhook.secret` *(string, default empty)*: Shared secret expected in the `Authorization` header. Ignored when empty.
107
+- `webhook.polling.enabled` *(bool, default `false`)*: Keep a registration active with the remote notification service and trigger periodic pulls.
108
+- `webhook.polling.endpoint` *(string, default empty)*: URL of the notification service (eg. Usage with [dn42notifyd](https://git.dn42.dev/dn42/dn42notifyd): `https://git.dn42/dn42notify/poll`).
109
+- `webhook.polling.callbackUrl` *(string, default empty)*: Public URL for `/api/webhook/pull`. Required when `webhook.polling.enabled` is `true`.
110
+- `webhook.polling.pollingIntervalSec` *(int, default `3600`)*: Seconds between refresh attempts. Must be positive when polling is enabled.
111
+- `webhook.polling.skipRemoteCert` *(bool, default `false`)*: Insecure: Skip TLS verification.
112
+
113
+### Paths and templating
114
+- `outputDir` *(string, default `./dist`)*: Destination directory for static builds or asset exports.
115
+- `templateDir` *(string, default `./template`)*: Location of layout templates and static assets bundled into the server/UI.
116
+- `homeDoc` *(string, default `Home.md`)*: Repository document to treat as the home page. Normalised to a `.md` path relative to the repo root.
117
+- `privatePagesPrefix` *(array of strings, default empty)*: Request to routes started with these prefixes will be blocked.
118
+
119
+### Layout and footer
120
+- `ignoreHeader` *(bool, default `false`)*: Skip loading `_Header.md` when `true`. Leave `false` to include the fragment when present.
121
+- `ignoreFooter` *(bool, default `false`)*: Skip `_Footer.md` when `true`; otherwise render it if available.
122
+- `serverFooter` *(string, default empty)*: Markdown snippet rendered into the global footer at runtime.
123
+
124
+### TLS
125
+- `enableTLS` *(bool, default `false`)*: Serve HTTPS using the provided certificate and key.
126
+- `tlsCert` *(string)*: Path to the TLS certificate. Required only when `enableTLS` is true.
127
+- `tlsKey` *(string)*: Path to the TLS private key. Required when `enableTLS` is true.
128
+
129
+### Logging and client IP handling
130
+- `logLevel` *(string, default `info`)*: Minimum log level (`debug`, `info`, `warn`, or `error`).
131
+- `trustedProxies` *(array of strings, default empty)*: CIDR blocks or literal IPs that are trusted to populate `X-Forwarded-For`.
132
+- `trustedRemoteAddrLevel` *(int, default `1`)*: Number of additional trusted hops to peel off when deriving the end-user IP from the forwarded chain. Values less than `1` are coerced to `1` during load.
133
+
134
+## Notes
135
+
136
+- live = true requires write access to the Git repo for local commits.
137
+- With no remote configured, `dn42-wiki-go` initializes a local-only repository.
138
+- Template changes require restarting the server or rebuilding static output.
18 139
19
-Instructions comming soon.