If not binding to an IP, add a Listen directive for a custom port if needed https://github.com/webmin/webmin/issues/2341

This commit is contained in:
Jamie Cameron
2024-12-21 15:41:33 -08:00
parent 19eb916cc1
commit 506f7a1819

View File

@@ -131,7 +131,7 @@ close(FILE);
foreach $a (@addrs) {
local $ip = &to_ipaddress($a);
if ($in{'listen'} && $ip) {
# add Listen if needed
# add Listen on the IP if needed
local @listen = &find_directive("Listen", $conf);
local $lfound;
foreach $l (@listen) {
@@ -189,6 +189,22 @@ foreach $a (@addrs) {
}
}
if ($in{'listen'} && $addr eq "*" && $portnum ne "*") {
# Add Listen on the port if needed
local @listen = &find_directive("Listen", $conf);
local $lfound;
foreach $l (@listen) {
$lfound++ if ($l eq '*' && $portnum == $defport ||
&check_ipaddress($l) && $portnum == $defport ||
$l =~ /:(\d+)$/ && $portnum == $1 ||
$l =~ /^\d+$/ && $portnum == $l);
}
if (!$lfound && @listen > 0) {
# Apache is not listening on the port for all IPs
&save_directive("Listen", [ @listen, $portnum ], $conf, $conf);
}
}
# Create the structure
if (@addrs) {
$ap = join(" ", map { $_.$port } @addrs);