NPM: use stable internal IP 10.10.10.3 for all API calls

The NPM API was reached via NPM_LAN_IP, which breaks when that value is a
placeholder or unset (and the :-10.10.10.103 fallback was wrong — the
internal IP is .3, not .103). NPM listens on all interfaces, so the host
can always reach it at 10.10.10.3:81 over vmbr1. NPM_LAN_IP now only drives
user-facing messages and the NPM LXC's LAN net0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-02 14:14:42 +00:00
parent 95632f22c9
commit d4b28dd41b

View file

@ -930,7 +930,7 @@ ${build_out}"
local npm_token local npm_token
npm_token=$(npm_get_token) npm_token=$(npm_get_token)
local npm_ip="${NPM_LAN_IP:-10.10.10.103}" local npm_ip="10.10.10.3" # stable internal NPM IP (vmbr1) — API only needs internal reach
if [[ -n "$npm_token" ]]; then if [[ -n "$npm_token" ]]; then
# Find the proxy host for our domain # Find the proxy host for our domain
local host_id local host_id
@ -1036,7 +1036,7 @@ ${build_out}"
# Add /hk-planner/ location to NPM proxy host # Add /hk-planner/ location to NPM proxy host
msg_info "Adding /hk-planner/ to NPM proxy" msg_info "Adding /hk-planner/ to NPM proxy"
local npm_token; npm_token=$(npm_get_token) local npm_token; npm_token=$(npm_get_token)
local npm_ip="${NPM_LAN_IP:-10.10.10.103}" local npm_ip="10.10.10.3" # stable internal NPM IP (vmbr1) — API only needs internal reach
if [[ -n "$npm_token" ]]; then if [[ -n "$npm_token" ]]; then
local host_id local host_id
host_id=$(curl -sf "http://${npm_ip}:81/api/nginx/proxy-hosts" \ host_id=$(curl -sf "http://${npm_ip}:81/api/nginx/proxy-hosts" \
@ -1081,7 +1081,7 @@ print(json.dumps(locs))
# Returns a Bearer token for the NPM API, or empty string on failure. # Returns a Bearer token for the NPM API, or empty string on failure.
npm_get_token() { npm_get_token() {
local npm_ip="${NPM_LAN_IP:-10.10.10.103}" local npm_ip="10.10.10.3" # stable internal NPM IP (vmbr1) — API only needs internal reach
local email="${NPM_ADMIN_EMAIL:-manage@hotel.com}" local email="${NPM_ADMIN_EMAIL:-manage@hotel.com}"
local pass="${NPM_ADMIN_PASS:-}" local pass="${NPM_ADMIN_PASS:-}"
[[ -z "$pass" ]] && { echo ""; return; } [[ -z "$pass" ]] && { echo ""; return; }
@ -1095,8 +1095,9 @@ configure_npm_proxy_hosts() {
msg_step "Configuring NPM proxy hosts" msg_step "Configuring NPM proxy hosts"
msg_info "Waiting for NPM API to be ready" msg_info "Waiting for NPM API to be ready"
local npm_ip="10.10.10.3" # stable internal NPM IP (vmbr1)
local i=0 local i=0
while ! curl -sf --max-time 3 "http://${NPM_LAN_IP}:81/api/" &>/dev/null; do while ! curl -sf --max-time 3 "http://${npm_ip}:81/api/" &>/dev/null; do
sleep 3; i=$((i+1)) sleep 3; i=$((i+1))
[[ $i -ge 30 ]] && { msg_warn "NPM API not responding — configure proxy hosts manually"; return; } [[ $i -ge 30 ]] && { msg_warn "NPM API not responding — configure proxy hosts manually"; return; }
done done
@ -1115,7 +1116,7 @@ configure_npm_proxy_hosts() {
# NPM already sets X-Real-IP / X-Forwarded-For by default, so no advanced_config. # NPM already sets X-Real-IP / X-Forwarded-For by default, so no advanced_config.
create_proxy_host() { create_proxy_host() {
local forward_host=$1 forward_port=$2 locations_json=${3:-'[]'} local forward_host=$1 forward_port=$2 locations_json=${3:-'[]'}
curl -sf -X POST "http://${NPM_LAN_IP}:81/api/nginx/proxy-hosts" \ curl -sf -X POST "http://${npm_ip}:81/api/nginx/proxy-hosts" \
-H "Authorization: Bearer ${token}" \ -H "Authorization: Bearer ${token}" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{ -d "{