diff options
-rw-r--r-- | config/haproxy/haproxy.inc | 27 | ||||
-rwxr-xr-x | config/haproxy/haproxy_backends_edit.php | 8 |
2 files changed, 25 insertions, 10 deletions
diff --git a/config/haproxy/haproxy.inc b/config/haproxy/haproxy.inc index e3028e4c..97c5b5a1 100644 --- a/config/haproxy/haproxy.inc +++ b/config/haproxy/haproxy.inc @@ -123,13 +123,26 @@ function haproxy_configure() { if(is_array($a_backends)) { foreach ($a_backends as $backend) { - if($backend['extaddr'] == "any") - $listenip = "listen {$backend['name']}\t\t\t0.0.0.0:".$backend['port']."\n"; - elseif($backend['extaddr']) - $listenip = "listen {$backend['name']}\t\t\t" . $backend['extaddr'] . ":" . $backend['port']."\n"; - else - $listenip = "listen {$backend['name']}\t\t\t" . get_current_wan_address('wan').":" . $backend['port']."\n"; - + // Define our backend name + $backend = "listen {$backend['name']}\n"; + + // Prepare ports for processing by splitting + $backend['port'] .= ","; + $ports = split(",", $backend['port']); + + // Process and add bind directives for ports + foreach($ports as $port) { + if($port) { + if($backend['extaddr'] == "any") + $listenip = "bind\t\t\t0.0.0.0:" . $port . "\n"; + elseif($backend['extaddr']) + $listenip = "bind\t\t\t" . $backend['extaddr'] . ":" . $port ."\n"; + else + $listenip = "bind\t\t\t" . get_current_wan_address('wan').":" . $port ."\n"; + } + } + + fwrite ($fd, "{$backend}"); fwrite ($fd, "{$listenip}"); fwrite ($fd, "\tmode\t\t\t".$backend['type'] . "\n"); fwrite ($fd, "\tlog\t\t\tglobal\n"); diff --git a/config/haproxy/haproxy_backends_edit.php b/config/haproxy/haproxy_backends_edit.php index 61915a70..fe92c5ed 100755 --- a/config/haproxy/haproxy_backends_edit.php +++ b/config/haproxy/haproxy_backends_edit.php @@ -120,8 +120,10 @@ if ($_POST) { if (!is_numeric($_POST['max_connections'])) $input_errors[] = "The field 'Max connections' value is not a number."; - if (!is_numeric($_POST['port'])) - $input_errors[] = "The field 'Port' value is not a number."; + $ports = $_POST['port']; + foreach($ports as $port) + if ($port && !is_numeric($port)) + $input_errors[] = "The field 'Port' value is not a number."; if (!is_numeric($_POST['client_timeout'])) $input_errors[] = "The field 'Client timeout' value is not a number."; @@ -498,7 +500,7 @@ set by the 'retries' parameter (2).</div> <td width="22%" valign="top" class="vncellreq">Port</td> <td width="78%" class="vtable" colspan="2"> <input name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="10" maxlength="10"> - <div>the port to listen to</div> + <div>The port to listen to. To specify multiple ports, separate with a comma (,). EXAMPLE: 80,443</div> </td> </tr> <tr> |