Docker WebUI links are not filled in (`http://[IP]:[PORT:8080]/`) when the server's IPv4 address is on a VLAN sub-interface such as `br0.60`

Aperta
#2,808 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
docker, php
Ambito
devops

Direzione di ricerca

Start in emhttp/plugins/dynamix.docker.manager/include/DockerClient.php, at DockerUtil::host(), which reads the IPv4 address of a single interface, and at DockerTemplates::getAllInfo(), where an empty IP leaves [IP] and [PORT:n] unreplaced. Also check the strpos check that keeps a WebUI URL already containing the server address. Done when a bridge with a VLAN sub-interface address and a hand-typed URL with [PORT:n] both produce a working link.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version: 7.3.0 (code unchanged in 7.3.4 and current master)

What happens: every container's WebUI link on the Docker tab opens the raw template, e.g. http://[IP]:[PORT:8080]/, which no browser can open. Templates where the user typed the server address by hand (http://192.168.60.10:[PORT:8080]/) are not filled in either: the port placeholder stays.

Setup that triggers it: the server's management IPv4 address lives on a VLAN sub-interface of the bridge, not on the bridge itself. Here: br0 has no IPv4 address, br0.60 has 192.168.60.10/24 (Settings → Network → VLANs, address only on the VLAN, untagged network without an address). Docker containers on bridge with published ports, on host, and on custom bridge networks are all affected.

Cause (emhttp/plugins/dynamix.docker.manager/include/DockerClient.php):

  1. DockerUtil::port() only tries br0, bond0, eth0, wlan0, and DockerUtil::host() then reads the IPv4 address of that one interface with ip -br -4 addr show $port scope global. When the address is on br0.60, host() returns an empty string. In DockerTemplates::getAllInfo() an empty $ip means the template URL is kept as is, so [IP] and [PORT:n] are never replaced.
  2. Separately, in getAllInfo() (line 365 in master): strpos($tmp['url'],$ip)!==false ? $tmp['url'] : $this->getControlURL(...). If the WebUI string already contains the server address, it is kept as is, also when it still holds a [PORT:n] placeholder. So a hand-typed http://<server-ip>:[PORT:8080]/ never gets its port filled in, even once the address lookup works.

Minimal fix we run locally (tested on 7.3.0):

// DockerUtil::host(): fall back to a VLAN sub-interface of the management port
$ip = exec("ip -br -4 addr show $port scope global | sed -r 's/\/[0-9]+//g' | awk '{print $3;exit}'");
return $ip ?: exec("ip -br -4 addr show scope global | sed -r 's/\/[0-9]+//g' | awk '$1 ~ /^$port\\./ {print $3;exit}'");
// getAllInfo(): only skip the fill-in when no [PORT:n] placeholder is left
$tmp['url'] = $ip ? (strpos($tmp['url'],$ip)!==false && !preg_match("%\[PORT:\d+\]%",$tmp['url']) ? $tmp['url'] : $this->getControlURL($ct, $ip, $tmp['url'])) : $tmp['url'];

In 7.3.4/master the same change applies inside the cached host() (return $cached = $ip ?: …). With both changes, all WebUI links on our server are built correctly again (host, bridge with port mapping, and custom bridge networks), without recreating any container or editing any template. port() is left alone on purpose: it also drives the docker.cfg network-key rename at the top of the file.

Expected: [IP] is filled with the server's management address wherever it lives (bridge, bond, or a VLAN sub-interface of either), and [PORT:n] is always filled in.

Lingua principale
PHP
Stelle
266
Fork
116
Merge medio
1g 5h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di unraid/webgui

Tutte le issue di unraid/webgui

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.