From 0731219bf01519e9f93c1c4b3c2c7c25f08df2bc Mon Sep 17 00:00:00 2001 From: PiBa-NL Date: Sat, 3 Aug 2013 17:14:32 +0200 Subject: HAProxy-devel, fix default backend selection --- config/haproxy-devel/haproxy.inc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'config/haproxy-devel/haproxy.inc') diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc index f871ddd7..f8434327 100644 --- a/config/haproxy-devel/haproxy.inc +++ b/config/haproxy-devel/haproxy.inc @@ -486,7 +486,7 @@ function write_backend($fd, $name, $pool, $frontend) { if (is_array($a_servers)) { foreach($a_servers as $be) { - if (!$be['status'] == "inactive") + if ($be['status'] == "inactive") continue; if (!$be['name']) @@ -728,7 +728,7 @@ function haproxy_writeconf($configfile) { // Combine the rest of the listener configs - $default_once = 0; + $default_backend = ""; $i = 0; foreach ($bind['config'] as $bconfig) { $a_acl=&$bconfig['ha_acls']['item']; @@ -742,9 +742,8 @@ function haproxy_writeconf($configfile) { $poolname .= "_" . $bconfig['svrport']; // Write this out once, and must be before any backend config text - if ($default_once == 0) { - fwrite ($fd, "\tdefault_backend\t\t" . $poolname . "\n"); - $default_once++; + if ($default_backend = "" || $bconfig['secondary'] != 'yes') { + $default_backend = $poolname; } if (!isset($a_pendingpl[$poolname])) { @@ -790,6 +789,8 @@ function haproxy_writeconf($configfile) { fwrite ($fd, "\tuse_backend\t\t" . $poolname . " if " . $aclnames . "\n"); } } + fwrite ($fd, "\tdefault_backend\t\t" . $default_backend . "\n"); + foreach($advancedextra as $extra) fwrite ($fd, "\t".$extra."\n"); fwrite ($fd, "\n"); -- cgit v1.2.3