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`

Abierto
#2,808 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
62/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
docker, php
Área
devops

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
PHP
Estrellas
266
Forks
116
Merge medio
1 d 5 h
PR fusionados (30 d)
4

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de unraid/webgui

Todos los issues de unraid/webgui

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.