aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-02-08 19:31:58 -0500
committerjim-p <jimp@pfsense.org>2015-02-08 19:31:58 -0500
commitda3cd59d595b075ff33901966065d62a213bae4c (patch)
treeacbcbe93b7380c733a7607fb30bee806352bad5b /config
parentef92cb6a05c293f5b05072ce8d7b3e1000515525 (diff)
parentcec43bb753d271b84aa6610315fdc02f784895c4 (diff)
downloadpfsense-packages-da3cd59d595b075ff33901966065d62a213bae4c.tar.gz
pfsense-packages-da3cd59d595b075ff33901966065d62a213bae4c.tar.bz2
pfsense-packages-da3cd59d595b075ff33901966065d62a213bae4c.zip
Merge pull request #814 from PiBa-NL/haproxy-devel_0_13
Diffstat (limited to 'config')
-rw-r--r--config/haproxy-devel/haproxy.inc21
1 files changed, 16 insertions, 5 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index a7394cf3..fd4262a5 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -1147,6 +1147,7 @@ function haproxy_writeconf($configpath) {
$default_backend = "";
$config_acls = "";
$config_usebackends = "";
+ $config_usedefaultbackends = "";
$transparent_clientip = false;
foreach ($bind['config'] as $frontend) {
@@ -1171,11 +1172,13 @@ function haproxy_writeconf($configpath) {
$backend = haproxy_find_backend($frontend['backend_serverpool']);
$transparent_clientip = $backend["transparent_clientip"] == 'yes';
+ $allowfordefaultbackend = true;
$ipv = array();
if ($transparent_clientip) {
if ($useipv4 && $useipv6) {
$ipv["ipv4"]['acl'] = " src_is_ipv4 ";
$ipv["ipv6"]['acl'] = " !src_is_ipv4 ";
+ $allowfordefaultbackend = false; // transparent backend must always match client-ip which is ipv4 v.s. ipv6 specific so there cannot be a default.
} else if ($useipv6)
$ipv["ipv6"]['acl'] = " ";
else
@@ -1217,10 +1220,12 @@ function haproxy_writeconf($configpath) {
$a_pendingpl[$poolname]['frontend'] = $bind;
$a_pendingpl[$poolname]['ipversion'] = $ipversion;
}
-
+ $canbedefaultbackend = false;
// Write this out once, and must be before any backend config text
if (($default_backend == "" || $frontend['secondary'] != 'yes') && count($a_acl) == 0 ) {
- $default_backend = $poolname;
+ $canbedefaultbackend = true;
+ if ($allowfordefaultbackend)
+ $default_backend = $poolname;
}
foreach ($a_acl_combine as $a_usebackend) {
@@ -1281,12 +1286,17 @@ function haproxy_writeconf($configpath) {
$y++;
}
- if (count($useracls) == 0) $useracls[] = ""; // add empty item to enter foreach loop at least once.
+ $systemacl = trim("{$certacl}{$ipversionoptions['acl']}");
+ if (!empty($systemacl) && count($useracls) == 0) $useracls[] = ""; // add empty item to enter foreach loop at least once when a system acl is pressent.
foreach($useracls as $useracl) {
$backendacl = "";
- $backendacl .= "|| {$useracl}{$certacl}{$ipversionoptions['acl']}";
+ $backendacl .= "|| {$useracl}{$systemacl}";
$backendacl = substr($backendacl, 3);
- $config_usebackends .= "\tuse_backend\t\t" . $poolname . " if " . $backendacl . "\n";
+ if ($canbedefaultbackend) {
+ // makes sure these come last even though systemacl's might have been added.
+ $config_usedefaultbackends .= "\tuse_backend\t\t" . $poolname . " if " . $backendacl . "\n";
+ } else
+ $config_usebackends .= "\tuse_backend\t\t" . $poolname . " if " . $backendacl . "\n";
}
}
}
@@ -1302,6 +1312,7 @@ function haproxy_writeconf($configpath) {
// Write backends after advanced options so custom use_backend rules can be applied first.
fwrite ($fd, $config_usebackends);
+ fwrite ($fd, $config_usedefaultbackends);
if ($default_backend)
fwrite ($fd, "\tdefault_backend\t\t" . $default_backend . "\n");