Skip to content

Commit 5ff212d

Browse files
committed
Fix config for new version
1 parent 7c2a8e3 commit 5ff212d

7 files changed

Lines changed: 76 additions & 56 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
6666

6767
# Run as root (no-new-privileges prevents privilege escalation via gosu/sudo)
6868
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
69-
CMD ["node", "dist/index.js", "gateway", "--bind", "lan", "--port", "18789", "--allow-unconfigured"]
69+
CMD ["node", "dist/index.js", "gateway", "--allow-unconfigured"]

docker-compose.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ services:
2929
- "node"
3030
- "dist/index.js"
3131
- "gateway"
32-
- "--bind"
33-
- "lan"
34-
- "--port"
35-
- "18789"
3632
- "--allow-unconfigured"
3733

3834
volumes:

entrypoint.sh

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,55 @@ OPENCLAW_DIR="${OPENCLAW_STATE_DIR:-/home/node/.openclaw}"
88
mkdir -p "$OPENCLAW_DIR/canvas" "$OPENCLAW_DIR/cron" "$OPENCLAW_DIR/workspace" "$OPENCLAW_DIR/sessions"
99

1010
# ---------------------------------------------------------------------------
11-
# Config is managed exclusively by the setup wizard (port 8080).
12-
# The entrypoint does NOT generate openclaw.json.
11+
# Ensure gateway config has controlUi origin setting (required for non-loopback)
1312
# ---------------------------------------------------------------------------
13+
CONFIG_FILE="$OPENCLAW_DIR/openclaw.json"
14+
if [ ! -f "$CONFIG_FILE" ]; then
15+
echo "Creating default OpenClaw config..."
16+
cat > "$CONFIG_FILE" << 'EOF'
17+
{
18+
"gateway": {
19+
"bind": "lan",
20+
"port": 18789,
21+
"controlUi": {
22+
"dangerouslyAllowHostHeaderOriginFallback": true,
23+
"allowInsecureAuth": true,
24+
"dangerouslyDisableDeviceAuth": true
25+
}
26+
}
27+
}
28+
EOF
29+
else
30+
node -e "
31+
const fs = require('fs');
32+
const JSON5 = require('/app/node_modules/json5');
33+
const configPath = '$CONFIG_FILE';
34+
try {
35+
const config = JSON5.parse(fs.readFileSync(configPath, 'utf8'));
36+
const cui = ((config.gateway = config.gateway || {}).controlUi = config.gateway.controlUi || {});
37+
const gw = config.gateway;
38+
let changed = false;
39+
if (!('bind' in gw)) { gw.bind = 'lan'; changed = true; }
40+
if (!('port' in gw)) { gw.port = 18789; changed = true; }
41+
if (!('dangerouslyAllowHostHeaderOriginFallback' in cui) && !('allowedOrigins' in cui)) {
42+
cui.dangerouslyAllowHostHeaderOriginFallback = true;
43+
changed = true;
44+
}
45+
if (!('allowInsecureAuth' in cui)) {
46+
cui.allowInsecureAuth = true;
47+
changed = true;
48+
}
49+
if (!('dangerouslyDisableDeviceAuth' in cui)) {
50+
cui.dangerouslyDisableDeviceAuth = true;
51+
changed = true;
52+
}
53+
if (changed) {
54+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
55+
console.log('Updated OpenClaw config for DAppNode HTTP deployment');
56+
}
57+
} catch(e) { console.warn('Could not update openclaw.json:', e.message); }
58+
" || true
59+
fi
1460

1561
# ---------------------------------------------------------------------------
1662
# Start setup wizard web UI in the background on port 8080

getting-started.md

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,5 @@
11
# OpenClaw
22

3-
Self-hosted AI gateway for DappNode
3+
Self-hosted AI gateway for DappNode.
44

5-
---
6-
7-
## Quick Links
8-
9-
- **[Open Setup Wizard](http://openclaw.dappnode:8080)** — Pick your AI provider, enter your API key, and start chatting in minutes.
10-
- **[Web UI](http://openclaw.dappnode:18789)** — Chat with AI models in your browser.
11-
- **[Terminal](http://openclaw.dappnode:7681)** — Shell access inside the container.
12-
13-
---
14-
15-
## Quick Start
16-
17-
1. **Run the Setup Wizard** — Click the link above or visit `:8080`. Choose a provider (OpenAI, Anthropic, Ollama, etc.), enter your API key, and pick a model.
18-
2. **Open the Web UI** — Go to `:18789` and start a conversation with your AI.
19-
3. **Connect messaging apps** — Optionally add Telegram, Discord, or other bots in the wizard so you can chat from any device.
20-
21-
> **Using Ollama?** Install an Ollama package on your DappNode first, then the wizard will auto-detect it.
22-
23-
---
24-
25-
## Supported Channels
26-
27-
Telegram · Discord · Slack · WhatsApp · Matrix · Web UI
28-
29-
---
30-
31-
## API Access
32-
33-
OpenClaw exposes an OpenAI-compatible API at `http://openclaw..dappnode:18789/api`. Use your gateway token for authentication.
34-
35-
---
36-
37-
## Troubleshooting
38-
39-
| Problem | Solution |
40-
|---|---|
41-
| **Gateway not reachable** | Check the container is running. Verify ports 18789/8080 are not blocked. |
42-
| **API key errors** | Re-enter your key in the wizard. Confirm your provider account has credits. |
43-
| **Bot not responding** | Verify bot tokens and permissions. Check logs via the terminal. |
44-
| **Debug from terminal** | Open the web terminal and run: `openclaw doctor` |
45-
46-
---
5+
Use the **[Setup Wizard](http://openclaw.dappnode:8080)** to configure your AI provider, API key, and preferred model. Once configured, open the **[Web UI](http://openclaw.dappnode:18789?token=openclaw)** to start chatting.

openclaw

Submodule openclaw updated 119 files

setup-wizard/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ <h2 style="text-align:center">Configuration Saved!</h2>
471471
Open Terminal
472472
<small>Run commands inside the container</small>
473473
</a>
474-
<a href="#" onclick="event.preventDefault(); goTo(0);">
474+
<a href="#" onclick="event.preventDefault(); location.reload();">
475475
Run Wizard Again
476476
<small>Reconfigure from scratch</small>
477477
</a>
@@ -1015,7 +1015,13 @@ <h2>Configure ${p.name}</h2>
10151015
useAccessGroups: false
10161016
},
10171017
gateway: {
1018-
controlUi: { allowInsecureAuth: true },
1018+
bind: "lan",
1019+
port: 18789,
1020+
controlUi: {
1021+
dangerouslyAllowHostHeaderOriginFallback: true,
1022+
allowInsecureAuth: true,
1023+
dangerouslyDisableDeviceAuth: true,
1024+
},
10191025
},
10201026
plugins: { entries: {} }
10211027
};

setup-wizard/server.cjs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ const http = require("node:http");
55
const fs = require("node:fs");
66
const path = require("node:path");
77

8+
function deepMerge(base, override) {
9+
if (typeof base !== "object" || base === null || Array.isArray(base)) return override;
10+
if (typeof override !== "object" || override === null || Array.isArray(override)) return override;
11+
const result = Object.assign({}, base);
12+
for (const key of Object.keys(override)) {
13+
result[key] = deepMerge(base[key], override[key]);
14+
}
15+
return result;
16+
}
17+
818
const PORT = 8080;
919
const CONFIG_DIR = process.env.OPENCLAW_STATE_DIR || "/home/node/.openclaw";
1020
const CONFIG_FILE = path.join(CONFIG_DIR, "openclaw.json");
@@ -78,13 +88,16 @@ const server = http.createServer(async (req, res) => {
7888
return;
7989
}
8090

81-
// Save config
91+
// Save config (deep-merge with existing so non-wizard settings are preserved)
8292
if (req.method === "POST" && url.pathname === "/api/config") {
8393
try {
8494
const body = await readBody(req);
85-
JSON.parse(body);
95+
const incoming = JSON.parse(body);
96+
let existing = {};
97+
try { existing = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8")); } catch {}
98+
const merged = deepMerge(existing, incoming);
8699
fs.mkdirSync(CONFIG_DIR, { recursive: true });
87-
fs.writeFileSync(CONFIG_FILE, body, "utf-8");
100+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2), "utf-8");
88101
json(res, 200, { ok: true, path: CONFIG_FILE });
89102
} catch (err) {
90103
json(res, 400, { error: err.message });

0 commit comments

Comments
 (0)