aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy/haproxy.inc
diff options
context:
space:
mode:
Diffstat (limited to 'config/haproxy/haproxy.inc')
-rw-r--r--config/haproxy/haproxy.inc27
1 files changed, 20 insertions, 7 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");