Commit 4497a242 authored by Franco Fichtner's avatar Franco Fichtner

system: split lb and pf sticky connection setting; closes #691

parent 003f6f93
...@@ -220,7 +220,7 @@ function relayd_configure($kill_first = false) ...@@ -220,7 +220,7 @@ function relayd_configure($kill_first = false)
$conf .= " listen on {$ip} port {$src_port}\n"; $conf .= " listen on {$ip} port {$src_port}\n";
$conf .= " forward to <{$vs_a[$i]['poolname']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['poolname']]['monitor']]} \n"; $conf .= " forward to <{$vs_a[$i]['poolname']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['poolname']]['monitor']]} \n";
if (isset($config['system']['lb_use_sticky'])) { if (isset($config['load_balancer']['setting']['lb_use_sticky'])) {
$conf .= " sticky-address\n"; $conf .= " sticky-address\n";
} }
......
...@@ -48,6 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -48,6 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['timeout'] = !empty($config['load_balancer']['setting']['timeout']) ? $config['load_balancer']['setting']['timeout'] : null; $pconfig['timeout'] = !empty($config['load_balancer']['setting']['timeout']) ? $config['load_balancer']['setting']['timeout'] : null;
$pconfig['interval'] = !empty($config['load_balancer']['setting']['interval']) ? $config['load_balancer']['setting']['interval'] : null; $pconfig['interval'] = !empty($config['load_balancer']['setting']['interval']) ? $config['load_balancer']['setting']['interval'] : null;
$pconfig['prefork'] = !empty($config['load_balancer']['setting']['prefork']) ? $config['load_balancer']['setting']['prefork'] : null; $pconfig['prefork'] = !empty($config['load_balancer']['setting']['prefork']) ? $config['load_balancer']['setting']['prefork'] : null;
$pconfig['lb_use_sticky'] = isset($config['load_balancer']['setting']['lb_use_sticky']);
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST; $pconfig = $_POST;
$input_errors = array(); $input_errors = array();
...@@ -78,6 +79,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -78,6 +79,13 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$config['load_balancer']['setting']['timeout'] = $pconfig['timeout']; $config['load_balancer']['setting']['timeout'] = $pconfig['timeout'];
$config['load_balancer']['setting']['interval'] = $pconfig['interval']; $config['load_balancer']['setting']['interval'] = $pconfig['interval'];
$config['load_balancer']['setting']['prefork'] = $pconfig['prefork']; $config['load_balancer']['setting']['prefork'] = $pconfig['prefork'];
if (!empty($pconfig['lb_use_sticky'])) {
$config['load_balancer']['setting']['lb_use_sticky'] = true;
} elseif (isset($config['load_balancer']['setting']['lb_use_sticky'])) {
unset($config['load_balancer']['setting']['lb_use_sticky']);
}
write_config(); write_config();
mark_subsystem_dirty('loadbalancer'); mark_subsystem_dirty('loadbalancer');
header("Location: load_balancer_setting.php"); header("Location: load_balancer_setting.php");
...@@ -116,7 +124,7 @@ include("head.inc"); ...@@ -116,7 +124,7 @@ include("head.inc");
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_timeout" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("timeout") ; ?></td> <td><a id="help_for_timeout" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Timeout") ; ?></td>
<td> <td>
<input type="text" name="timeout" id="timeout" value="<?=$pconfig['timeout'];?>" /> <input type="text" name="timeout" id="timeout" value="<?=$pconfig['timeout'];?>" />
<div class="hidden" for="help_for_timeout"> <div class="hidden" for="help_for_timeout">
...@@ -125,7 +133,7 @@ include("head.inc"); ...@@ -125,7 +133,7 @@ include("head.inc");
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_interval" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("interval") ; ?></td> <td><a id="help_for_interval" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Interval") ; ?></td>
<td> <td>
<input type="text" name="interval" id="interval" value="<?=$pconfig['interval']; ?>"/> <input type="text" name="interval" id="interval" value="<?=$pconfig['interval']; ?>"/>
<div class="hidden" for="help_for_interval"> <div class="hidden" for="help_for_interval">
...@@ -134,7 +142,7 @@ include("head.inc"); ...@@ -134,7 +142,7 @@ include("head.inc");
</td> </td>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_prefork" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("prefork") ; ?></td> <td><a id="help_for_prefork" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Prefork") ; ?></td>
<td> <td>
<input type="text" name="prefork" id="prefork" value="<?=$pconfig['prefork']; ?>"/> <input type="text" name="prefork" id="prefork" value="<?=$pconfig['prefork']; ?>"/>
<div class="hidden" for="help_for_prefork"> <div class="hidden" for="help_for_prefork">
...@@ -142,6 +150,22 @@ include("head.inc"); ...@@ -142,6 +150,22 @@ include("head.inc");
</div> </div>
</td> </td>
</tr> </tr>
<tr>
<td><a id="help_for_lb_use_sticky" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Sticky connections");?> </td>
<td>
<input name="lb_use_sticky" type="checkbox" id="lb_use_sticky" value="yes" <?= !empty($pconfig['lb_use_sticky']) ? 'checked="checked"' : '';?>/>
<strong><?=gettext("Use sticky connections"); ?></strong><br />
<div class="hidden" for="help_for_lb_use_sticky">
<?=gettext("Successive connections will be redirected to the servers " .
"in a round-robin manner with connections from the same " .
"source being sent to the same web server. This 'sticky " .
"connection' will exist as long as there are states that " .
"refer to this connection. Once the states expire, so will " .
"the sticky connection. Further connections from that host " .
"will be redirected to the next web server in the round-robin."); ?>
</div>
</td>
</tr>
<tr> <tr>
<td>&nbsp;</td> <td>&nbsp;</td>
<td> <td>
......
...@@ -108,16 +108,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -108,16 +108,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$input_errors[] = gettext("The Reflection timeout must be an integer."); $input_errors[] = gettext("The Reflection timeout must be an integer.");
} }
if (count($input_errors) == 0) { if (count($input_errors) == 0) {
$need_relayd_restart = false;
if (!empty($pconfig['lb_use_sticky'])) { if (!empty($pconfig['lb_use_sticky'])) {
if (!isset($config['system']['lb_use_sticky'])) { $config['system']['lb_use_sticky'] = true;
$config['system']['lb_use_sticky'] = true;
$need_relayd_restart = true;
}
} elseif (isset($config['system']['lb_use_sticky'])) { } elseif (isset($config['system']['lb_use_sticky'])) {
unset($config['system']['lb_use_sticky']); unset($config['system']['lb_use_sticky']);
$need_relayd_restart = true;
} }
if (!empty($pconfig['srctrack'])) { if (!empty($pconfig['srctrack'])) {
...@@ -269,9 +264,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { ...@@ -269,9 +264,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
configure_cron(); configure_cron();
filter_configure(); filter_configure();
if ($need_relayd_restart) {
relayd_configure();
}
} }
} }
...@@ -462,7 +454,7 @@ include("head.inc"); ...@@ -462,7 +454,7 @@ include("head.inc");
</td> </td>
</tr> </tr>
<tr> <tr>
<th colspan="2" valign="top" class="listtopic"><?= gettext('Load Balancing') ?></th> <th colspan="2" valign="top" class="listtopic"><?= gettext('Multi-WAN') ?></th>
</tr> </tr>
<tr> <tr>
<td><a id="help_for_lb_use_sticky" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Sticky connections");?> </td> <td><a id="help_for_lb_use_sticky" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Sticky connections");?> </td>
...@@ -472,16 +464,15 @@ include("head.inc"); ...@@ -472,16 +464,15 @@ include("head.inc");
<div class="hidden" for="help_for_lb_use_sticky"> <div class="hidden" for="help_for_lb_use_sticky">
<?=gettext("Successive connections will be redirected to the servers " . <?=gettext("Successive connections will be redirected to the servers " .
"in a round-robin manner with connections from the same " . "in a round-robin manner with connections from the same " .
"source being sent to the same web server. This 'sticky " . "source being sent to the same gateway. This 'sticky " .
"connection' will exist as long as there are states that " . "connection' will exist as long as there are states that " .
"refer to this connection. Once the states expire, so will " . "refer to this connection. Once the states expire, so will " .
"the sticky connection. Further connections from that host " . "the sticky connection. Further connections from that host " .
"will be redirected to the next web server in the round " . "will be redirected to the next gateway in the round-robin."); ?>
"robin. Changing this option will restart the Load Balancing service."); ?>
</div><br/> </div><br/>
<input placeholder="<?=gettext("Source tracking timeout");?>" title="<?=gettext("Source tracking timeout");?>" name="srctrack" id="srctrack" type="text" value="<?= !empty($pconfig['srctrack']) ? $pconfig['srctrack'] : "";?>"/> <input placeholder="<?=gettext("Source tracking timeout");?>" title="<?=gettext("Source tracking timeout");?>" name="srctrack" id="srctrack" type="text" value="<?= !empty($pconfig['srctrack']) ? $pconfig['srctrack'] : "";?>"/>
<div class="hidden" for="help_for_lb_use_sticky"> <div class="hidden" for="help_for_lb_use_sticky">
<?=gettext("Set the source tracking timeout for sticky connections. " . <?=gettext("Set the source tracking timeout for sticky connections in seconds. " .
"By default this is 0, so source tracking is removed as soon as the state expires. " . "By default this is 0, so source tracking is removed as soon as the state expires. " .
"Setting this timeout higher will cause the source/destination relationship to persist for longer periods of time."); ?> "Setting this timeout higher will cause the source/destination relationship to persist for longer periods of time."); ?>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment