added proxy support

This commit is contained in:
macm1
2026-02-22 19:51:17 +03:00
parent e33bcf030a
commit c3ba720d0b
4 changed files with 46 additions and 1 deletions
+1
View File
@@ -7,6 +7,7 @@ All notable changes to the OpenClaw Assistant Home Assistant Add-on will be docu
### Changed ### Changed
- Bump OpenClaw to 2026.2.21-2. - Bump OpenClaw to 2026.2.21-2.
- Add Home Assistant `share` and `media` mounts to the add-on (`map: share:rw, media:rw`). - Add Home Assistant `share` and `media` mounts to the add-on (`map: share:rw, media:rw`).
- Keep official OpenClaw npm release and add startup proxy shim for `HTTP_PROXY/HTTPS_PROXY` support in undici fetch.
## [0.5.47] - 2026-02-21 ## [0.5.47] - 2026-02-21
+2 -1
View File
@@ -100,7 +100,7 @@ RUN if [ -x /home/linuxbrew/.linuxbrew/bin/brew ]; then \
fi fi
USER root USER root
# Install OpenClaw globally # Install OpenClaw globally (official npm release)
RUN npm config set fund false && npm config set audit false \ RUN npm config set fund false && npm config set audit false \
&& npm install -g openclaw@2026.2.21-2 && npm install -g openclaw@2026.2.21-2
@@ -124,6 +124,7 @@ fi
EOF EOF
COPY run.sh /run.sh COPY run.sh /run.sh
COPY oc_config_helper.py /oc_config_helper.py COPY oc_config_helper.py /oc_config_helper.py
COPY openclaw-proxy-shim.cjs /usr/local/lib/openclaw-proxy-shim.cjs
COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl COPY nginx.conf.tpl /etc/nginx/nginx.conf.tpl
COPY landing.html.tpl /etc/nginx/landing.html.tpl COPY landing.html.tpl /etc/nginx/landing.html.tpl
RUN chmod +x /run.sh /oc_config_helper.py \ RUN chmod +x /run.sh /oc_config_helper.py \
@@ -0,0 +1,29 @@
"use strict";
/**
* Enable HTTP(S) proxy support for Node/undici before OpenClaw initializes.
* We load undici from OpenClaw's own node_modules path to avoid relying on
* global module resolution from this shim's location.
*/
(function applyProxyFromEnv() {
const hasProxyEnv =
!!process.env.HTTPS_PROXY ||
!!process.env.HTTP_PROXY ||
!!process.env.https_proxy ||
!!process.env.http_proxy;
if (!hasProxyEnv) {
return;
}
try {
const path = require("node:path");
const globalModulesRoot =
process.env.OPENCLAW_GLOBAL_NODE_MODULES || "/usr/lib/node_modules";
const undiciPath = path.join(globalModulesRoot, "openclaw", "node_modules", "undici");
const { EnvHttpProxyAgent, setGlobalDispatcher } = require(undiciPath);
setGlobalDispatcher(new EnvHttpProxyAgent());
} catch (_err) {
// Keep startup resilient if module layout changes in future releases.
}
})();
+14
View File
@@ -347,6 +347,20 @@ else
echo "INFO: Run 'openclaw onboard' first, then restart the add-on" echo "INFO: Run 'openclaw onboard' first, then restart the add-on"
fi fi
# ------------------------------------------------------------------------------
# Proxy shim for undici/OpenClaw startup
# Keep official OpenClaw npm release while enabling HTTP(S)_PROXY support.
# ------------------------------------------------------------------------------
OPENCLAW_GLOBAL_NODE_MODULES="$(HOME=/root npm root -g 2>/dev/null || true)"
if [ -f /usr/local/lib/openclaw-proxy-shim.cjs ]; then
if [ -n "${NODE_OPTIONS:-}" ]; then
export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs ${NODE_OPTIONS}"
else
export NODE_OPTIONS="--require /usr/local/lib/openclaw-proxy-shim.cjs"
fi
export OPENCLAW_GLOBAL_NODE_MODULES
fi
echo "Starting OpenClaw Assistant gateway (openclaw)..." echo "Starting OpenClaw Assistant gateway (openclaw)..."
openclaw gateway run & openclaw gateway run &
GW_PID=$! GW_PID=$!