aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel/www
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2015-10-24 17:12:29 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2015-10-24 17:20:51 +0200
commite1dda0cf2125650b29f07d6931f133cfc58fce57 (patch)
tree6d0434ebe4100e3f8f566579a4bc6ea962db533e /config/haproxy-devel/www
parent914bc8d64109a36d7f1182cb048d39cb409c8433 (diff)
downloadpfsense-packages-e1dda0cf2125650b29f07d6931f133cfc58fce57.tar.gz
pfsense-packages-e1dda0cf2125650b29f07d6931f133cfc58fce57.tar.bz2
pfsense-packages-e1dda0cf2125650b29f07d6931f133cfc58fce57.zip
haproxy-devel, pkg v0.32 allow usage of mailers/dns/'actions', rework of acl system.
Diffstat (limited to 'config/haproxy-devel/www')
-rw-r--r--config/haproxy-devel/www/haproxy_files.php32
-rw-r--r--config/haproxy-devel/www/haproxy_global.php112
-rw-r--r--config/haproxy-devel/www/haproxy_listeners.php39
-rw-r--r--config/haproxy-devel/www/haproxy_listeners_edit.php439
-rw-r--r--config/haproxy-devel/www/haproxy_pool_edit.php234
-rw-r--r--config/haproxy-devel/www/haproxy_pools.php8
-rw-r--r--config/haproxy-devel/www/haproxy_stats.php34
-rw-r--r--config/haproxy-devel/www/haproxy_templates.php4
8 files changed, 596 insertions, 306 deletions
diff --git a/config/haproxy-devel/www/haproxy_files.php b/config/haproxy-devel/www/haproxy_files.php
index 12ab5a88..4fe6bf45 100644
--- a/config/haproxy-devel/www/haproxy_files.php
+++ b/config/haproxy-devel/www/haproxy_files.php
@@ -42,15 +42,20 @@ if (!is_array($a_pools)) $a_pools = array();
$fields_files = array();
$fields_files[0]['name']="name";
$fields_files[0]['columnheader']="Name";
-$fields_files[0]['colwidth']="30%";
+$fields_files[0]['colwidth']="20%";
$fields_files[0]['type']="textbox";
$fields_files[0]['size']="20";
-
-$fields_files[1]['name']="content";
-$fields_files[1]['columnheader']="content";
-$fields_files[1]['colwidth']="70%";
-$fields_files[1]['type']="textarea";
-$fields_files[1]['size']="70";
+$fields_files[1]['name']="type";
+$fields_files[1]['columnheader']="Type";
+$fields_files[1]['colwidth']="10%";
+$fields_files[1]['type']="select";
+$fields_files[1]['size']="10";
+$fields_files[1]['items']=$a_filestype;
+$fields_files[2]['name']="content";
+$fields_files[2]['columnheader']="content";
+$fields_files[2]['colwidth']="70%";
+$fields_files[2]['type']="textarea";
+$fields_files[2]['size']="70";
$fileslist = new HaproxyHtmlList("table_files", $fields_files);
$fileslist->keyfield = "name";
@@ -63,7 +68,7 @@ if ($_POST) {
if ($result)
unlink_if_exists($d_haproxyconfdirty_path);
} else {
- $a_files = $fileslist->haproxy_htmllist_get_values($fields_files);
+ $a_files = $fileslist->haproxy_htmllist_get_values();
$filedupcheck = array();
foreach($a_files as $key => $file) {
@@ -77,7 +82,7 @@ if ($_POST) {
// replace references in backends to renamed 'files'
foreach($a_pools as &$backend) {
- if (is_arrayset($backend,'errorfiles','item'))
+ if (is_arrayset($backend,'errorfiles','item')) {
foreach($backend['errorfiles']['item'] as &$errorfile) {
$found = false;
foreach($a_files as $key => $file) {
@@ -86,9 +91,11 @@ if ($_POST) {
$found = true;
}
}
- if (!$found)
+ if (!$found) {
$input_errors[] = "Errorfile marked for deletion: " . $errorfile['errorfile'] . " which is used in backend " . $backend['name'];
+ }
}
+ }
}
if (!$input_errors) {
// save config when no errors found
@@ -100,10 +107,9 @@ if ($_POST) {
}
}
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-
$pgtitle = "Services: HAProxy: Files";
include("head.inc");
+haproxy_css();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
@@ -165,7 +171,7 @@ include("head.inc");
<script type="text/javascript">
totalrows = <?php echo $counter; ?>;
<?
- phparray_to_javascriptarray($fields_files,"fields_files",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
+ $fileslist->outputjavascript();
?>
</script>
diff --git a/config/haproxy-devel/www/haproxy_global.php b/config/haproxy-devel/www/haproxy_global.php
index 2ae92256..ff021be0 100644
--- a/config/haproxy-devel/www/haproxy_global.php
+++ b/config/haproxy-devel/www/haproxy_global.php
@@ -38,12 +38,13 @@ require_once("pkg_haproxy_tabs.inc");
require_once("haproxy_htmllist.inc");
$simplefields = array('localstats_refreshtime', 'localstats_sticktable_refreshtime', 'log-send-hostname', 'ssldefaultdhparam',
- 'email_level', 'email_myhostname', 'email_from', 'email_to');
+ 'email_level', 'email_myhostname', 'email_from', 'email_to',
+ 'resolver_retries', 'resolver_timeoutretry', 'resolver_holdvalid');
$none = array();
$none['']['name'] = "Dont log";
$a_sysloglevel = $none + $a_sysloglevel;
-
+
$fields_mailers = array();
$fields_mailers[0]['name'] = "name";
$fields_mailers[0]['columnheader'] = "Name";
@@ -61,8 +62,27 @@ $fields_mailers[2]['colwidth'] = "10%";
$fields_mailers[2]['type'] = "textbox";
$fields_mailers[2]['size'] = "10";
+$fields_resolvers = array();
+$fields_resolvers[0]['name'] = "name";
+$fields_resolvers[0]['columnheader'] = "Name";
+$fields_resolvers[0]['colwidth'] = "30%";
+$fields_resolvers[0]['type'] = "textbox";
+$fields_resolvers[0]['size'] = "20";
+$fields_resolvers[1]['name'] = "server";
+$fields_resolvers[1]['columnheader'] = "DNSserver";
+$fields_resolvers[1]['colwidth'] = "60%";
+$fields_resolvers[1]['type'] = "textbox";
+$fields_resolvers[1]['size'] = "60";
+$fields_resolvers[2]['name'] = "port";
+$fields_resolvers[2]['columnheader'] = "DNSport";
+$fields_resolvers[2]['colwidth'] = "10%";
+$fields_resolvers[2]['type'] = "textbox";
+$fields_resolvers[2]['size'] = "10";
+
$mailerslist = new HaproxyHtmlList("table_mailers", $fields_mailers);
$mailerslist->keyfield = "name";
+$resolverslist = new HaproxyHtmlList("table_resolvers", $fields_resolvers);
+$resolverslist->keyfield = "name";
if (!is_array($config['installedpackages']['haproxy']))
$config['installedpackages']['haproxy'] = array();
@@ -82,7 +102,7 @@ if ($_POST) {
unlink_if_exists($d_haproxyconfdirty_path);
} else {
$a_mailers = $mailerslist->haproxy_htmllist_get_values();
- $pool['ha_servers']['item'] = $a_servers;
+ $a_resolvers = $resolverslist->haproxy_htmllist_get_values();
if ($_POST['carpdev'] == "disabled")
unset($_POST['carpdev']);
@@ -99,28 +119,18 @@ if ($_POST) {
if ($_POST['localstats_sticktable_refreshtime'] && (!is_numeric($_POST['localstats_sticktable_refreshtime'])))
$input_errors[] = "The local stats sticktable refresh time should be numeric or empty.";
- /*if($_POST['synchost1'] && !is_ipaddr($_POST['synchost1']))
- $input_errors[] = "Synchost1 needs to be an IPAddress.";
- if($_POST['synchost2'] && !is_ipaddr($_POST['synchost2']))
- $input_errors[] = "Synchost2 needs to be an IPAddress.";
- if($_POST['synchost3'] && !is_ipaddr($_POST['synchost3']))
- $input_errors[] = "Synchost3 needs to be an IPAddress.";*/
-
if (!$input_errors) {
- $config['installedpackages']['haproxy']['email_mailers']['items'] = $a_mailers;
+ $config['installedpackages']['haproxy']['email_mailers']['item'] = $a_mailers;
+ $config['installedpackages']['haproxy']['dns_resolvers']['item'] = $a_resolvers;
$config['installedpackages']['haproxy']['enable'] = $_POST['enable'] ? true : false;
$config['installedpackages']['haproxy']['terminate_on_reload'] = $_POST['terminate_on_reload'] ? true : false;
$config['installedpackages']['haproxy']['maxconn'] = $_POST['maxconn'] ? $_POST['maxconn'] : false;
$config['installedpackages']['haproxy']['enablesync'] = $_POST['enablesync'] ? true : false;
- //$config['installedpackages']['haproxy']['synchost1'] = $_POST['synchost1'] ? $_POST['synchost1'] : false;
- //$config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost2'] ? $_POST['synchost2'] : false;
- //$config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost3'] ? $_POST['synchost3'] : false;
$config['installedpackages']['haproxy']['remotesyslog'] = $_POST['remotesyslog'] ? $_POST['remotesyslog'] : false;
$config['installedpackages']['haproxy']['logfacility'] = $_POST['logfacility'] ? $_POST['logfacility'] : false;
$config['installedpackages']['haproxy']['loglevel'] = $_POST['loglevel'] ? $_POST['loglevel'] : false;
$config['installedpackages']['haproxy']['carpdev'] = $_POST['carpdev'] ? $_POST['carpdev'] : false;
- //$config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false;
$config['installedpackages']['haproxy']['localstatsport'] = $_POST['localstatsport'] ? $_POST['localstatsport'] : false;
$config['installedpackages']['haproxy']['advanced'] = $_POST['advanced'] ? base64_encode($_POST['advanced']) : false;
$config['installedpackages']['haproxy']['nbproc'] = $_POST['nbproc'] ? $_POST['nbproc'] : false;
@@ -132,16 +142,13 @@ if ($_POST) {
}
}
-$a_mailers = $config['installedpackages']['haproxy']['email_mailers']['items'];
+$a_mailers = $config['installedpackages']['haproxy']['email_mailers']['item'];
+$a_resolvers = $config['installedpackages']['haproxy']['dns_resolvers']['item'];
$pconfig['enable'] = isset($config['installedpackages']['haproxy']['enable']);
$pconfig['terminate_on_reload'] = isset($config['installedpackages']['haproxy']['terminate_on_reload']);
$pconfig['maxconn'] = $config['installedpackages']['haproxy']['maxconn'];
$pconfig['enablesync'] = isset($config['installedpackages']['haproxy']['enablesync']);
-//$pconfig['syncpassword'] = $config['installedpackages']['haproxy']['syncpassword'];
-//$pconfig['synchost1'] = $config['installedpackages']['haproxy']['synchost1'];
-//$pconfig['synchost2'] = $config['installedpackages']['haproxy']['synchost2'];
-//$pconfig['synchost3'] = $config['installedpackages']['haproxy']['synchost3'];
$pconfig['remotesyslog'] = $config['installedpackages']['haproxy']['remotesyslog'];
$pconfig['logfacility'] = $config['installedpackages']['haproxy']['logfacility'];
$pconfig['loglevel'] = $config['installedpackages']['haproxy']['loglevel'];
@@ -158,13 +165,9 @@ if (!$pconfig['logfacility'])
if (!$pconfig['loglevel'])
$pconfig['loglevel'] = 'info';
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version < 2.0)
- $one_two = true;
-
$pgtitle = "Services: HAProxy: Settings";
include("head.inc");
-
+haproxy_css();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<script type="text/javascript" src="javascript/scriptaculous/prototype.js"></script>
@@ -179,9 +182,6 @@ function enable_change(enable_change) {
}
//-->
</script>
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
<form action="haproxy_global.php" method="post" name="iform">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
@@ -210,7 +210,7 @@ function enable_change(enable_change) {
<tr>
<td width="22%" valign="top" class="vncell">Installed version:</td>
<td width="78%" class="vtable">
- <strong><?=haproxy_verion()?></strong>
+ <strong><?=haproxy_version()?></strong>
</td>
</tr>
<tr>
@@ -400,9 +400,55 @@ function enable_change(enable_change) {
</td>
</tr>
<tr><td>&nbsp;</td></tr>
- <? if (haproxy_verion() >= '1.6' ) { ?>
+ <? if (haproxy_version() >= '1.6-dev4' ) { ?>
<tr>
- <td colspan="2" valign="top" class="listtopic">Email notifications</td>
+ <td colspan="2" valign="top" class="listtopic">Global DNS resolvers for haproxy</td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell">
+ DNS servers
+ </td>
+ <td class="vtable">
+ Configuring DNS servers will allow haproxy to detect when a servers IP changes to a different one in 'elastic' environments without needing to be restarted.
+ <br/>
+ <?
+ $counter=0;
+ $resolverslist->Draw($a_resolvers);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell">
+ 'resolver_retries'
+ </td>
+ <td class="vtable">
+ <input name="resolver_retries" type="text" <?if(isset($pconfig['resolver_retries'])) echo "value=\"{$pconfig['resolver_retries']}\"";?> size="50"/><br/>
+ Email address to be used as the sender of the emails.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell">
+ 'resolver_timeoutretry'
+ </td>
+ <td class="vtable">
+ <input name="resolver_timeoutretry" type="text" <?if(isset($pconfig['resolver_timeoutretry'])) echo "value=\"{$pconfig['resolver_timeoutretry']}\"";?> size="50"/><br/>
+ Email address to be used as the sender of the emails.
+ </td>
+ </tr>
+ <tr>
+ <td valign="top" class="vncell">
+ 'resolver_holdvalid'
+ </td>
+ <td class="vtable">
+ <input name="resolver_holdvalid" type="text" <?if(isset($pconfig['resolver_holdvalid'])) echo "value=\"{$pconfig['resolver_holdvalid']}\"";?> size="50"/><br/>
+ Email address to be used as the sender of the emails.
+ </td>
+ </tr>
+ <tr><td>&nbsp;</td></tr>
+ <? }
+ if (haproxy_version() >= '1.6' ) { ?>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic">Global email notifications</td>
</tr>
<tr>
<td valign="top" class="vncell">
@@ -412,7 +458,6 @@ function enable_change(enable_change) {
It is possible to send email alerts when the state of servers changes. If configured email alerts are sent to each mailer that is configured in a mailers section. Email is sent to mailers using SMTP.
<br/>
<?
- $counter=0;
$mailerslist->Draw($a_mailers);
?>
</td>
@@ -582,7 +627,8 @@ haproxy_htmllist_js();
<script type="text/javascript">
totalrows = <?php echo $counter; ?>;
<?
- phparray_to_javascriptarray($fields_mailers,"fields_mailers",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
+ $mailerslist->outputjavascript();
+ $resolverslist->outputjavascript();
?>
function scroll_after_fade() {
diff --git a/config/haproxy-devel/www/haproxy_listeners.php b/config/haproxy-devel/www/haproxy_listeners.php
index db1f3ff2..2a91aa3f 100644
--- a/config/haproxy-devel/www/haproxy_listeners.php
+++ b/config/haproxy-devel/www/haproxy_listeners.php
@@ -95,7 +95,7 @@ if ($_GET['act'] == "del") {
$pgtitle = "Services: HAProxy: Frontends";
include("head.inc");
-
+haproxy_css();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
@@ -182,7 +182,7 @@ function js_callback(req) {
$first = true;
$last_frontend_shared = false;
foreach ($a_frontend_grouped as $a_frontend) {
- usort($a_frontend,'sort_sharedfrontends');
+ usort($a_frontend, 'sort_sharedfrontends');
if ((count($a_frontend) > 1 || $last_frontend_shared) && !$first) {
?> <tr class="<?=$textgray?>"><td colspan="7">&nbsp;</td></tr> <?
}
@@ -297,14 +297,37 @@ function js_callback(req) {
</td>
<td class="listr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$frontendname;?>';">
<div title='<?=$backend_serverpool_hint;?>'>
- <a href="haproxy_pool_edit.php?id=<?=$frontend['backend_serverpool']?>">
- <?=$frontend['backend_serverpool']?>
- </a>
+ <?
+ $first = true;
+ if (is_array($frontend['a_actionitems']['item'])) {
+ foreach ($frontend['a_actionitems']['item'] as $actionitem) {
+ if ($actionitem['action'] == "use_backend") {
+ if ($first) {
+ $first = false;
+ } else {
+ echo "<br/>";
+ }
+ $backend = $actionitem['use_backendbackend'];
+ echo "<a href='haproxy_pool_edit.php?id={$backend}'>{$backend}</a>";
+
+ if (!empty($actionitem['acl'])) {
+ echo " if({$actionitem['acl']})";
+ }
+ }
+ }
+ }
+ $backend = $frontend['backend_serverpool'];
+ if (!empty($backend)) {
+ if ($first) {
+ $first = false;
+ } else {
+ echo "<br/>";
+ }
+ echo "<a href='haproxy_pool_edit.php?id={$backend}'>{$backend}</a> (default)";
+ }
+ ?>
</div>
</td>
- <!--td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$frontendname;?>';">
- <?=$frontend['secondary'] == 'yes' ? $frontend['primary_frontend'] : "";?>
- </td-->
<td class="list" nowrap>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
diff --git a/config/haproxy-devel/www/haproxy_listeners_edit.php b/config/haproxy-devel/www/haproxy_listeners_edit.php
index 6998e099..799cb3cd 100644
--- a/config/haproxy-devel/www/haproxy_listeners_edit.php
+++ b/config/haproxy-devel/www/haproxy_listeners_edit.php
@@ -47,17 +47,6 @@ if (!function_exists("cert_get_purpose")) {
}
/**/
-function haproxy_js_acl_select($mode) {
- global $a_acltypes;
-
- $seltext = '';
- foreach ($a_acltypes as $key => $expr) {
- if ($expr['mode'] == '' || $expr['mode'] == $mode)
- $seltext .= "<option value='" . $key . "'>" . $expr['name'] ."<\/option>";
- }
- return $seltext;
-}
-
if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
$config['installedpackages']['haproxy']['ha_backends']['item'] = array();
}
@@ -71,7 +60,8 @@ uasort($a_pools, haproxy_compareByName);
global $simplefields;
$simplefields = array('name','desc','status','secondary','primary_frontend','type','forwardfor','httpclose','extaddr','backend_serverpool',
'max_connections','client_timeout','port','advanced_bind',
- 'ssloffloadcert','dcertadv','ssloffload','ssloffloadacl','ssloffloadacladditional','sslclientcert-none','sslclientcert-invalid','sslocsp',
+ 'ssloffloadcert','dcertadv','ssloffload','ssloffloadacl','ssloffloadacl_an','ssloffloadacladditional','ssloffloadacladditional_an',
+ 'sslclientcert-none','sslclientcert-invalid','sslocsp',
'socket-stats',
'dontlognull','dontlog-normal','log-separate-errors','log-detailed');
@@ -88,7 +78,7 @@ $id = get_frontend_id($id);
if (!is_numeric($id))
{
//default value for new items.
- $pconfig['ssloffloadacl'] = "yes";
+ $pconfig['ssloffloadacl_an'] = "yes";
$new_item = array();
$new_item['extaddr'] = "wan_ipv4";
$new_item['extaddr_port'] = "80";
@@ -182,12 +172,110 @@ $fields_externalAddress[4]['colwidth']="20%";
$fields_externalAddress[4]['type']="textbox";
$fields_externalAddress[4]['size']="30";
+$fields_actions=array();
+$fields_actions[0]['name']="action";
+$fields_actions[0]['columnheader']="Action";
+$fields_actions[0]['colwidth']="30%";
+$fields_actions[0]['type']="select";
+$fields_actions[0]['size']="200px";
+$fields_actions[0]['items']=&$a_action;
+$fields_actions[1]['name']="parameters";
+$fields_actions[1]['columnheader']="Parameters";
+$fields_actions[1]['colwidth']="30%";
+$fields_actions[1]['type']="fixedtext";
+$fields_actions[1]['size']="200px";
+$fields_actions[1]['text']="See below";
+$fields_actions[2]['name']="acl";
+$fields_actions[2]['columnheader']="Condition acl names";
+$fields_actions[2]['colwidth']="15%";
+$fields_actions[2]['type']="textbox";
+$fields_actions[2]['size']="40";
+
+$a_files = haproxy_get_fileslist();
+$fields_errorfile = array();
+$fields_errorfile[0]['name']="errorcode";
+$fields_errorfile[0]['columnheader']="errorcode(s)";
+$fields_errorfile[0]['colwidth']="15%";
+$fields_errorfile[0]['type']="textbox";
+$fields_errorfile[0]['size']="70px";
+$fields_errorfile[1]['name']="errorfile";
+$fields_errorfile[1]['columnheader']="Error Page";
+$fields_errorfile[1]['colwidth']="30%";
+$fields_errorfile[1]['type']="select";
+$fields_errorfile[1]['size']="170px";
+$fields_errorfile[1]['items']=&$a_files;
+
+$backends = get_haproxy_backends();
+$a_action['use_backend']['fields']['backend']['items'] = &$backends;
+//$a_action['http-request_lua']['fields']['lua-script']['items'] = &$a_files;
+//$a_action['tcp-request_content_lua']['fields']['lua-script']['items'] = &$a_files;
+
+$fields_actions_details=array();
+foreach($a_action as $key => $action) {
+ if (is_array($action['fields'])) {
+ foreach($action['fields'] as $field) {
+ $item = $field;
+ $name = $key . $item['name'];
+ $item['name'] = $name;
+ $item['columnheader'] = $field['name'];
+ $item['customdrawcell'] = customdrawcell_actions;
+ $fields_actions_details[$name] = $item;
+ }
+ }
+}
+
+$a_acltypes["backendservercount"]['fields']['backend']['items'] = &$backends;
+$fields_acl_details=array();
+foreach($a_acltypes as $key => $action) {
+ if (is_array($action['fields'])) {
+ foreach($action['fields'] as $field) {
+ $item = $field;
+ $name = $key . $item['name'];
+ $item['name'] = $name;
+ $item['columnheader'] = $field['name'];
+ $item['customdrawcell'] = customdrawcell_actions;
+ $fields_acl_details[$name] = $item;
+ }
+ }
+}
+
+function customdrawcell_actions($object, $item, $itemvalue, $editable, $itemname, $counter) {
+ if ($editable) {
+ $object->haproxy_htmllist_drawcell($item, $itemvalue, $editable, $itemname, $counter);
+ } else {
+ //TODO hide fields not applicable.?.
+ echo $itemvalue;
+ }
+}
+
+$htmllist_extaddr = new HaproxyHtmlList("table_extaddr", $fields_externalAddress);
+$htmllist_extaddr->editmode = true;
+
+$htmllist_acls = new HaproxyHtmlList("table_acls", $fields_aclSelectionList);
+$htmllist_acls->fields_details = $fields_acl_details;
+$htmllist_acls->editmode = true;
+
+$htmllist_actions = new HaproxyHtmlList("table_actions", $fields_actions);
+$htmllist_actions->fields_details = $fields_actions_details;
+$htmllist_actions->keyfield = "name";
+//$htmllist_actions->editmode = true;
+
+$htmllist_sslCertificates = new HaproxyHtmlList("tbl_sslCerts", $fields_sslCertificates);
+$htmllist_caCertificates = new HaproxyHtmlList("tbl_caCerts", $fields_caCertificates );
+$htmllist_crlCertificates = new HaproxyHtmlList("tbl_crlCerts", $fields_crlCertificates);
+
+$errorfileslist = new HaproxyHtmlList("table_errorfile", $fields_errorfile);
+$errorfileslist->keyfield = "errorcode";
+
if (isset($id) && $a_backend[$id]) {
$pconfig['a_acl']=&$a_backend[$id]['ha_acls']['item'];
$pconfig['a_certificates']=&$a_backend[$id]['ha_certificates']['item'];
$pconfig['clientcert_ca']=&$a_backend[$id]['clientcert_ca']['item'];
$pconfig['clientcert_crl']=&$a_backend[$id]['clientcert_crl']['item'];
$pconfig['a_extaddr']=&$a_backend[$id]['a_extaddr']['item'];
+ $pconfig['a_actionitems']=&$a_backend[$id]['a_actionitems']['item'];
+ $pconfig['a_errorfiles']=&$a_backend[$id]['a_errorfiles']['item'];
+
$pconfig['advanced'] = base64_decode($a_backend[$id]['advanced']);
foreach($simplefields as $stat)
$pconfig[$stat] = $a_backend[$id][$stat];
@@ -243,20 +331,23 @@ if ($_POST) {
if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_backends']['item'][$i]['name']) && ($i != $id))
$input_errors[] = "This frontend name has already been used. Frontend names must be unique. $i != $id";
- $a_certificates = haproxy_htmllist_get_values($fields_sslCertificates);
+ $a_actionitems = $htmllist_actions->haproxy_htmllist_get_values();
+ $pconfig['a_actionitems'] = $a_actionitems;
+ $a_errorfiles = $errorfileslist->haproxy_htmllist_get_values();
+ $pconfig['a_errorfiles'] = $a_errorfiles;
+ $a_certificates = $htmllist_sslCertificates->haproxy_htmllist_get_values();
$pconfig['a_certificates'] = $a_certificates;
- $a_clientcert_ca = haproxy_htmllist_get_values($fields_caCertificates);
+ $a_clientcert_ca = $htmllist_caCertificates->haproxy_htmllist_get_values();
$pconfig['clientcert_ca'] = $a_clientcert_ca;
- $a_clientcert_crl = haproxy_htmllist_get_values($fields_crlCertificates);
+ $a_clientcert_crl = $htmllist_crlCertificates->haproxy_htmllist_get_values();
$pconfig['clientcert_crl'] = $a_clientcert_crl;
- $a_acl = haproxy_htmllist_get_values($fields_aclSelectionList);
+ $a_acl = $htmllist_acls->haproxy_htmllist_get_values();
$pconfig['a_acl'] = $a_acl;
- $a_extaddr = haproxy_htmllist_get_values($fields_externalAddress);
+ $a_extaddr = $htmllist_extaddr->haproxy_htmllist_get_values();
$pconfig['a_extaddr'] = $a_extaddr;
-
foreach($a_acl as $acl) {
$acl_name = $acl['name'];
$acl_value = $acl['value'];
@@ -311,6 +402,8 @@ if ($_POST) {
$backend['clientcert_ca']['item'] = $a_clientcert_ca;
$backend['clientcert_crl']['item'] = $a_clientcert_crl;
$backend['a_extaddr']['item'] = $a_extaddr;
+ $backend['a_actionitems']['item'] = $a_actionitems;
+ $backend['a_errorfiles']['item'] = $a_errorfiles;
if (isset($id) && $a_backend[$id]) {
$a_backend[$id] = $backend;
@@ -328,13 +421,10 @@ if ($_POST) {
}
}
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version < 2.0)
- $one_two = true;
-
$closehead = false;
$pgtitle = "HAProxy: Frontend: Edit";
include("head.inc");
+haproxy_css();
if (!isset($_GET['dup']))
$excludefrontend = $pconfig['name'];
@@ -353,50 +443,28 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<?php if($one_two): ?>
-<script type="text/javascript" src="/javascript/scriptaculous/prototype.js"></script>
-<script type="text/javascript" src="/javascript/scriptaculous/scriptaculous.js"></script>
-<?php endif; ?>
-
<script type="text/javascript">
- function htmllist_get_select_options(tableId, fieldname) {
- var seltext;
- seltext = "";
- var type;
- var secondary = d.getElementById("secondary");
- var primary_frontend = d.getElementById("primary_frontend");
- if ((secondary !== null) && (secondary.checked))
- type = primaryfrontends[primary_frontend.value]['ref']['type'];
- else
- type = d.getElementById("type").value;
-
- if (tableId == 'tableA_acltable'){
- if (type == 'health')
- seltext = "<?php echo haproxy_js_acl_select('health');?>";
- else if (type == 'tcp')
- seltext = "<?php echo haproxy_js_acl_select('tcp');?>";
- else if (type == 'https')
- seltext = "<?php echo haproxy_js_acl_select('https');?>";
+ function htmllist_get_select_options(tableId, fieldname, itemstable) {
+ if (tableId == 'table_acls' && fieldname == 'expression') {
+ var type;
+ var secondary = d.getElementById("secondary");
+ var primary_frontend = d.getElementById("primary_frontend");
+ if ((secondary !== null) && (secondary.checked))
+ type = primaryfrontends[primary_frontend.value]['ref']['type'];
else
- seltext = "<?php echo haproxy_js_acl_select('http');?>";
- if (seltext == '') {
- alert("No ACL types available in current frontend type");
- return;
+ type = d.getElementById("type").value;
+
+ result = Object.create(null);
+ for (var key in itemstable) {
+ newitem = itemstable[key];
+ if (newitem['mode'] == type || newitem['mode'] == "") {
+ result[key] = newitem;
+ result[key]['name'] = result[key]['name'];
+ }
}
+ return result;
}
- if (tableId == 'tableA_sslCertificates'){
- seltext = "<?=haproxy_js_select_options($servercerts);?>";
- }
- if (tableId == 'table_clientcert_ca'){
- seltext = "<?=haproxy_js_select_options($certs_ca);?>";
- }
- if (tableId == 'table_clientcert_crl'){
- seltext = "<?=haproxy_js_select_options($certs_crl);?>";
- }
- if (tableId == 'table_extaddr'){
- seltext = "<?=haproxy_js_select_options($interfaces);?>";
- }
- return seltext;
+ return itemstable;
}
function setCSSdisplay(cssID, display) {
@@ -430,7 +498,7 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
} else {
type = d.getElementById("type").value;
for (i = 0; i < 99; i++) {
- customEdit = document.getElementById("extaddr_ssl"+i);
+ customEdit = document.getElementById("table_extaddr"+"extaddr_ssl"+i);
if (customEdit && customEdit.checked)
sslshow = true;
}
@@ -462,47 +530,31 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
d = document;
for (i = 0; i < 99; i++) {
- el = d.getElementById("acl_expression" + i);
- row = d.getElementById("aclrow" + i);
- if (!el)
- continue;
- for (j = 0; j < count; j++) {
- if (acl[j] == el.value) {
- if (mode[j] != '' && mode[j] != type) {
- Effect.Fade(row,{ duration: 1.0 });
- } else {
- Effect.Appear(row,{ duration: 1.0 });
- }
- }
- }
- }
-
- for (i = 0; i < 99; i++) {
- el = d.getElementById("expression" + i);
- //row_v = d.getElementById("tr_view_" + i);
+ el = d.getElementById("table_acls" + "expression" + i);
row_e = d.getElementById("tr_edit_" + i);
- if (!el)
+ row_v = d.getElementById("tr_viewdetail_" + i);
+ if (!el || !row_e)
continue;
for (j = 0; j < count; j++) {
if (acl[j] == el.value) {
if (mode[j] != '' && mode[j] != type) {
- //Effect.Fade(row_v,{ duration: 1.0 });
Effect.Fade(row_e,{ duration: 1.0 });
+ if (row_v) {
+ Effect.Fade(row_v,{ duration: 1.0 });
+ }
} else {
- //Effect.Appear(row_v,{ duration: 1.0 });
Effect.Appear(row_e,{ duration: 1.0 });
+ if (row_v) {
+ Effect.Appear(row_v,{ duration: 1.0 });
+ }
}
}
}
}
-
}
</script>
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
<form action="haproxy_listeners_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
@@ -566,21 +618,19 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
<?
$counter=0;
$a_extaddr = $pconfig['a_extaddr'];
- $htmllist_extadd = new HaproxyHtmlList("table_extaddr", $fields_externalAddress);
- $htmllist_extadd->editmode = true;
- $htmllist_extadd->Draw($a_extaddr);
+ $htmllist_extaddr->Draw($a_extaddr);
?>
<script type="text/javascript">
- function table_extaddr_row_added(tableid, rowid){
- new AutoSuggestControl(document.getElementById("extaddr_custom"+rowid), new StateSuggestions(address_array));
- new AutoSuggestControl(document.getElementById("extaddr_port"+rowid), new StateSuggestions(port_array));
- table_extaddr_listitem_change(tableid,"",rowid, null);//disables address when not set to custom.
+ function table_extaddr_row_added(tableId, rowId){
+ new AutoSuggestControl(document.getElementById(tableId+"extaddr_custom"+rowId), new StateSuggestions(address_array));
+ new AutoSuggestControl(document.getElementById(tableId+"extaddr_port"+rowId), new StateSuggestions(port_array));
+ table_extaddr_listitem_change(tableId,"",rowId, null);//disables address when not set to custom.
}
function table_extaddr_listitem_change(tableId, fieldId, rowNr, field) {
if (fieldId == "extaddr" || fieldId == "") {
- field = field || document.getElementById("extaddr"+rowNr);
- customEdit = document.getElementById("extaddr_custom"+rowNr);
+ field = field || document.getElementById(tableId+"extaddr"+rowNr);
+ customEdit = document.getElementById(tableId+"extaddr_custom"+rowNr);
customdisabled = field.value == "custom" ? 0 : 1;
customEdit.disabled = customdisabled;
}
@@ -607,23 +657,6 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
<input name="max_connections" type="text" <?if(isset($pconfig['max_connections'])) echo "value=\"{$pconfig['max_connections']}\"";?> size="10" maxlength="10" />
</td>
</tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">Backend server pool</td>
- <td width="78%" class="vtable">
-
- <select id="backend_serverpool" name="backend_serverpool" class="formfld">
- <?php
- if (is_array($a_pools)) {
- foreach ($a_pools as $p) {
- $selected = $p['name'] == $pconfig['backend_serverpool'] ? 'selected' : '';
- $name = htmlspecialchars("{$p['name']}");
- echo "<option value=\"{$p['name']}\" $selected>$name</option>";
- }
- } else {
- echo "<option value=\"-\">-</option>";
- }
- ?>
- </select>
<tr class="haproxy_primary" align="left">
<td width="22%" valign="top" class="vncellreq">Type</td>
<td width="78%" class="vtable" colspan="2">
@@ -644,11 +677,74 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
<td width="78%" class="vtable" colspan="2" valign="top">
<?
$a_acl = $pconfig['a_acl'];
- haproxy_htmllist("tableA_acltable", $a_acl, $fields_aclSelectionList, true);
+ $htmllist_acls->Draw($a_acl);
?>
<br/>
- acl's with the same name wil be 'combined', acl's with different names will be evaluated seperately.<br/>
- For more information about ACL's please see <a href='http://haproxy.1wt.eu/download/1.5/doc/configuration.txt' target='_blank'>HAProxy Documentation</a> Section 7 - Using ACL's
+ Example:
+ <table border='1' style='border-collapse:collapse'>
+ <tr>
+ <td><b>Name</b></td>
+ <td><b>Expression</b></td>
+ <td><b>Not</b></td>
+ <td><b>Value</b></td>
+ </tr>
+ <tr>
+ <td>Backend1acl</td>
+ <td>Host matches</td>
+ <td></td>
+ <td>www.yourdomain.tld</td>
+ </tr>
+ <tr>
+ <td>addHeaderAcl</td>
+ <td>SSL Client certificate valid</td>
+ <td></td>
+ <td></td>
+ </tr>
+ </table>
+ <br/>
+ acl's with the same name will be 'combined' using OR criteria.<br/>
+ For more information about ACL's please see <a href='http://haproxy.1wt.eu/download/1.5/doc/configuration.txt' target='_blank'>HAProxy Documentation</a> Section 7 - Using ACL's<br/><br/>
+ <strong>NOTE Important change in behaviour, since package version 0.32</strong><br/>
+ -acl's are no longer combined with logical AND operators, list multiple acl's below where needed.<br/>
+ -acl's alone no longer implicitly generate use_backend configuration. Add 'actions' below to accomplish this behaviour.
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Actions</td>
+ <td width="78%" class="vtable" colspan="2" valign="top">
+ <?
+ $a_actionitems = $pconfig['a_actionitems'];
+ $htmllist_actions->Draw($a_actionitems);
+ ?>
+ <br/>
+ Example:
+ <table border='1' style='border-collapse:collapse'>
+ <tr>
+ <td><b>Action</b></td>
+ <td><b>Parameters</b></td>
+ <td><b>Condition</b></td>
+ </tr>
+ <tr>
+ <td>Use Backend</td>
+ <td>Website1Backend</td>
+ <td>Backend1acl</td>
+ </tr>
+ <tr>
+ <td>http-request header set</td>
+ <td>Headername: X-HEADER-ClientCertValid<br/>New logformat value: YES</td>
+ <td>addHeaderAcl</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">Default Backend</td>
+ <td width="78%" class="vtable">
+ <?php
+ $listitem_none['']['name']="None";
+ $backends = $listitem_none + $backends;
+ echo_html_select("backend_serverpool", $backends, $pconfig['backend_serverpool'] ? $pconfig['backend_serverpool'] : "none", "", "updatevisibility();");
+ ?>
</td>
</tr>
<tr class="haproxy_primary"><td>&nbsp;</td></tr>
@@ -704,6 +800,23 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
address and ports. In http mode also the HTTP request and captured headers and cookies will be logged.</div>
</td>
</tr>
+ <tr><td>&nbsp;</td></tr>
+ <tr>
+ <td colspan="2" valign="top" class="listtopic">Error files</td>
+ </tr>
+ <tr class="" align="left" id='errorfiles'>
+ <td colspan="2" valign="top" class="vtable">
+ Use these to replace the error pages that haproxy can generate by custom pages created on the files tab.
+ For example haproxy will generate a 503 error page when no backend is available, you can replace that page here.
+ <br/>
+ <br/>
+ <?
+ $a_errorfiles = $pconfig['a_errorfiles'];
+ $errorfileslist->Draw($a_errorfiles);
+ ?>
+ </td>
+ </tr>
+ <tr><td>&nbsp;</td></tr>
</table>
<br/>&nbsp;<br/>
<table class="haproxy_primary" width="100%" border="0" cellpadding="6" cellspacing="0">
@@ -785,6 +898,7 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
Choose the cert to use on this frontend.
<br/>
<input id="ssloffloadacl" name="ssloffloadacl" type="checkbox" value="yes" <?php if ($pconfig['ssloffloadacl']=='yes') echo "checked";?> onclick="updatevisibility();" />Add ACL for certificate CommonName. (host header matches the 'CN' of the certificate)<br/>
+ <input id="ssloffloadacl_an" name="ssloffloadacl_an" type="checkbox" value="yes" <?php if ($pconfig['ssloffloadacl_an']=='yes') echo "checked";?> onclick="updatevisibility();" />Add ACL for certificate Subject Alternative Names.<br/>
</td>
</tr>
<tr class="haproxy_ssloffloading_enabled" align="left">
@@ -799,10 +913,12 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
Which of these certificate will be send will be determined by haproxys SNI recognition. If the browser does not send SNI this will not work properly. (IE on XP is one example, possibly also older browsers or mobile devices)
<?
$a_certificates = $pconfig['a_certificates'];
- haproxy_htmllist("tableA_sslCertificates", $a_certificates, $fields_sslCertificates);
+ //haproxy_htmllist("tableA_sslCertificates", $a_certificates, $fields_sslCertificates);
+ $htmllist_sslCertificates->Draw($a_certificates);
?>
<br/>
<input id="ssloffloadacladditional" name="ssloffloadacladditional" type="checkbox" value="yes" <?php if ($pconfig['ssloffloadacladditional']=='yes') echo "checked";?> onclick="updatevisibility();" />Add ACL for certificate CommonName. (host header matches the 'CN' of the certificate)<br/>
+ <input id="ssloffloadacladditional_an" name="ssloffloadacladditional_an" type="checkbox" value="yes" <?php if ($pconfig['ssloffloadacladditional_an']=='yes') echo "checked";?> onclick="updatevisibility();" />Add ACL for certificate Subject Alternative Names.<br/>
</td>
</tr>
<tr class="haproxy_ssloffloading_enabled haproxy_primary" align="left">
@@ -843,7 +959,7 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
Client certificate will be verified against these CA certificates.
<?
$a_certificates = $pconfig['clientcert_ca'];
- haproxy_htmllist("table_clientcert_ca", $a_certificates, $fields_caCertificates);
+ $htmllist_caCertificates->Draw($a_certificates);
?>
</td>
</tr>
@@ -853,7 +969,7 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
Client certificate will be verified against these CRL revocation lists.
<?
$a_certificates = $pconfig['clientcert_crl'];
- haproxy_htmllist("table_clientcert_crl", $a_certificates, $fields_crlCertificates);
+ $htmllist_crlCertificates->Draw($a_certificates);
?>
</td>
</tr>
@@ -883,15 +999,26 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
<br/>
<script type="text/javascript">
<?
+ // On gui descriptions when a closetype has been selected..
+ phparray_to_javascriptarray($a_closetypes, "closetypes", Array('/*', '/*/name', '/*/descr'));
+
+ // To find 'type' of frontend to show proper acl's ??
phparray_to_javascriptarray($primaryfrontends,"primaryfrontends",Array('/*',
- '/*/name','/*/ref','/*/ref/type','/*/ref/a_extaddr','/*/ref/a_extaddr/item','/*/ref/a_extaddr/item/*',
+ '/*/name', '/*/ref', '/*/ref/type', '/*/ref/a_extaddr', '/*/ref/a_extaddr/item', '/*/ref/a_extaddr/item/*',
'/*/ref/a_extaddr/item/*/extaddr_ssl'));
- phparray_to_javascriptarray($a_closetypes,"closetypes",Array('/*','/*/name','/*/descr'));
- phparray_to_javascriptarray($fields_sslCertificates,"fields_sslCertificates",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
- phparray_to_javascriptarray($fields_caCertificates,"fields_ca",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
- phparray_to_javascriptarray($fields_crlCertificates,"fields_crl",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
- phparray_to_javascriptarray($fields_aclSelectionList,"fields_acltable",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
- phparray_to_javascriptarray($fields_externalAddress,"fields_extaddr",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
+
+ phparray_to_javascriptarray($a_action, "showhide_actionfields",
+ Array('/*', '/*/fields', '/*/fields/*', '/*/fields/*/name'));
+ phparray_to_javascriptarray($a_acltypes, "showhide_aclfields",
+ Array('/*', '/*/fields', '/*/fields/*', '/*/fields/*/name'));
+
+ $htmllist_extaddr->outputjavascript();
+ $htmllist_acls->outputjavascript();
+ $htmllist_actions->outputjavascript();
+ $errorfileslist->outputjavascript();
+ $htmllist_sslCertificates->outputjavascript();
+ $htmllist_caCertificates->outputjavascript();
+ $htmllist_crlCertificates->outputjavascript();
?>
</script>
<script type="text/javascript">
@@ -902,12 +1029,64 @@ $primaryfrontends = get_haproxy_frontends($excludefrontend);
for(i=0;i < <?=count($a_extaddr)?>;i++){
- new AutoSuggestControl(document.getElementById('extaddr_custom'+i), new StateSuggestions(address_array));
- new AutoSuggestControl(document.getElementById('extaddr_port'+i), new StateSuggestions(port_array));
+ new AutoSuggestControl(document.getElementById('table_extaddrextaddr_custom'+i), new StateSuggestions(address_array));
+ new AutoSuggestControl(document.getElementById('table_extaddrextaddr_port'+i), new StateSuggestions(port_array));
// Initially set fields disabled where needed
table_extaddr_listitem_change('table_extaddr','',i,null);
}
+ function table_acls_listitem_change(tableId, fieldId, rowNr, field) {
+ if (fieldId = "toggle_details") {
+ fieldId = "expression";
+ field = d.getElementById(tableId+"expression"+rowNr);
+ }
+ if (fieldId = "expression") {
+ var actiontype = field.value;
+
+ var table = d.getElementById(tableId);
+
+ for(var actionkey in showhide_aclfields) {
+ var fields = showhide_aclfields[actionkey]['fields'];
+ for(var fieldkey in fields){
+ var fieldname = fields[fieldkey]['name'];
+ var rowid = "tr_edititemdetails_"+rowNr+"_"+actionkey+fieldname;
+ var element = d.getElementById(rowid);
+
+ if (actionkey == actiontype)
+ element.style.display = '';
+ else
+ element.style.display = 'none';
+ }
+ }
+ }
+ }
+
+ function table_actions_listitem_change(tableId, fieldId, rowNr, field) {
+ if (fieldId = "toggle_details") {
+ fieldId = "action";
+ field = d.getElementById(tableId+"action"+rowNr);
+ }
+ if (fieldId = "action") {
+ var actiontype = field.value;
+
+ var table = d.getElementById(tableId);
+
+ for(var actionkey in showhide_actionfields) {
+ var fields = showhide_actionfields[actionkey]['fields'];
+ for(var fieldkey in fields){
+ var fieldname = fields[fieldkey]['name'];
+ var rowid = "tr_edititemdetails_"+rowNr+"_"+actionkey+fieldname;
+ var element = d.getElementById(rowid);
+
+ if (actionkey == actiontype)
+ element.style.display = '';
+ else
+ element.style.display = 'none';
+ }
+ }
+ }
+ }
+
updatevisibility();
</script>
<?php
diff --git a/config/haproxy-devel/www/haproxy_pool_edit.php b/config/haproxy-devel/www/haproxy_pool_edit.php
index 6cd78741..13444f4d 100644
--- a/config/haproxy-devel/www/haproxy_pool_edit.php
+++ b/config/haproxy-devel/www/haproxy_pool_edit.php
@@ -58,7 +58,9 @@ if (isset($_GET['dup']))
global $simplefields;
$simplefields = array(
-"name","balance","transparent_clientip","transparent_interface",
+"name",
+"balance","balance_urilen","balance_uridepth","balance_uriwhole",
+"transparent_clientip","transparent_interface",
"check_type","checkinter","log-health-checks","httpcheck_method","monitor_uri","monitor_httpversion","monitor_username","monitor_domain","monitor_agentport",
"agent_check","agent_port","agent_inter",
"connection_timeout","server_timeout","retries",
@@ -194,14 +196,23 @@ $fields_errorfile[1]['type']="select";
$fields_errorfile[1]['size']="170px";
$fields_errorfile[1]['items']=&$a_files;
+$serverslist = new HaproxyHtmlList("tableA_servers", $fields_servers);
+$serverslist->keyfield = "name";
+$serverslist->fields_details = $fields_servers_details;
+
+$errorfileslist = new HaproxyHtmlList("table_errorfile", $fields_errorfile);
+$errorfileslist->keyfield = "errorcode";
+
+
if (isset($id) && $a_pools[$id]) {
$pconfig['advanced'] = base64_decode($a_pools[$id]['advanced']);
$pconfig['advanced_backend'] = base64_decode($a_pools[$id]['advanced_backend']);
- $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item'];
+ $a_servers = &$a_pools[$id]['ha_servers']['item'];
foreach($simplefields as $stat)
$pconfig[$stat] = $a_pools[$id][$stat];
+
$a_errorfiles = &$a_pools[$id]['errorfiles']['item'];
if (!is_array($a_errorfiles)) $a_errorfiles = array();
}
@@ -265,7 +276,7 @@ if ($_POST) {
if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_pools']['item'][$i]['name']) && ($i != $id))
$input_errors[] = "This pool name has already been used. Pool names must be unique.";
- $a_servers = haproxy_htmllist_get_values(array_merge($fields_servers,$fields_servers_details));
+ $a_servers = $serverslist->haproxy_htmllist_get_values();
foreach($a_servers as $server){
$server_name = $server['name'];
$server_address = $server['address'];
@@ -294,66 +305,59 @@ if ($_POST) {
$input_errors[] = "The field 'Port' value is not a number.";
}
- $a_errorfiles = haproxy_htmllist_get_values($fields_errorfile);
+ $a_errorfiles = $errorfileslist->haproxy_htmllist_get_values();
if ($_POST['strict_transport_security'] !== "" && !is_numeric($_POST['strict_transport_security']))
$input_errors[] = "The field 'Strict-Transport-Security' is not empty or a number.";
-// if (!$input_errors) {
- $pool = array();
- if(isset($id) && $a_pools[$id])
- $pool = $a_pools[$id];
-
- if ($pool['name'] != $_POST['name']) {
- // name changed:
- if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
- $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
- }
- $a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
+ $pool = array();
+ if(isset($id) && $a_pools[$id])
+ $pool = $a_pools[$id];
+
+ if ($pool['name'] != $_POST['name']) {
+ // name changed:
+ if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
+ }
+ $a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
- for ( $i = 0; $i < count($a_backend); $i++) {
- if ($a_backend[$i]['backend_serverpool'] == $pool['name'])
- $a_backend[$i]['backend_serverpool'] = $_POST['name'];
- }
+ for ( $i = 0; $i < count($a_backend); $i++) {
+ if ($a_backend[$i]['backend_serverpool'] == $pool['name'])
+ $a_backend[$i]['backend_serverpool'] = $_POST['name'];
}
+ }
- if($pool['name'] != "")
- $changedesc .= " modified pool: '{$pool['name']}'";
+ if($pool['name'] != "")
+ $changedesc .= " modified pool: '{$pool['name']}'";
- $pool['ha_servers']['item']=$a_servers;
+ $pool['ha_servers']['item']=$a_servers;
- update_if_changed("advanced", $pool['advanced'], base64_encode($_POST['advanced']));
- update_if_changed("advanced_backend", $pool['advanced_backend'], base64_encode($_POST['advanced_backend']));
+ update_if_changed("advanced", $pool['advanced'], base64_encode($_POST['advanced']));
+ update_if_changed("advanced_backend", $pool['advanced_backend'], base64_encode($_POST['advanced_backend']));
- global $simplefields;
- foreach($simplefields as $stat)
- update_if_changed($stat, $pool[$stat], $_POST[$stat]);
-
- if (isset($id) && $a_pools[$id]) {
- $a_pools[$id] = $pool;
- } else {
- $a_pools[] = $pool;
- }
+ global $simplefields;
+ foreach($simplefields as $stat)
+ update_if_changed($stat, $pool[$stat], $_POST[$stat]);
+
+ if (isset($id) && $a_pools[$id]) {
+ $a_pools[$id] = $pool;
+ } else {
+ $a_pools[] = $pool;
+ }
if (!isset($input_errors)) {
if ($changecount > 0) {
touch($d_haproxyconfdirty_path);
- write_config($changedesc);
- /*
- echo "<PRE>";
- print_r($config);
- echo "</PRE>";
- */
+ write_config($changedesc);
}
-
header("Location: haproxy_pools.php");
exit;
}
- $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item'];
}
$closehead = false;
$pgtitle = "HAProxy: Backend server pool: Edit";
include("head.inc");
+haproxy_css();
// 'processing' done, make all simple fields usable in html.
foreach($simplefields as $field){
@@ -379,16 +383,6 @@ foreach($simplefields as $field){
</head>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<script type="text/javascript">
- function htmllist_get_select_options(tableId, fieldname) {
- if (fieldname == 'forwardto')
- return "<?=haproxy_js_select_options($primaryfrontends);?>";
- else
- if (fieldname == 'errorfile')
- return "<?=haproxy_js_select_options($a_files);?>";
- else
- return "<?=haproxy_js_select_options($a_servermodes);?>";
- }
-
function clearcombo(){
for (var i=document.iform.serversSelect.options.length-1; i>=0; i--){
document.iform.serversSelect.options[i] = null;
@@ -498,8 +492,7 @@ foreach($simplefields as $field){
</span>
<?
$counter=0;
- $a_servers = $pconfig['a_servers'];
- haproxy_htmllist("tableA_servers", $a_servers, $fields_servers, null, $fields_servers_details);
+ $serverslist->Draw($a_servers);
?>
<table class="haproxy_help_serverlist" style="border:1px dashed green" cellspacing="0">
<tr><td class="vncell">
@@ -528,66 +521,104 @@ foreach($simplefields as $field){
<tr align="left">
<td width="22%" valign="top" class="vncellreq">Balance</td>
<td width="78%" class="vtable" colspan="1">
- <table width="100%">
+ <table width="100%" cellspacing="0">
+ <tr>
+ <td class="vncell" width="25%" valign="top">
+ <input type="radio" name="balance" value=""<?php if(empty($pconfig['balance'])) echo " CHECKED"; ?> />None
+ </td>
+ <td class="vncell">
+ This allows writing your own custom balance settings into the advanced section.
+ Or when you have no need for balancing with only 1 server.
+ </td>
+ </tr>
<tr>
- <td width="25%" valign="top">
+ <td class="vncell" width="25%" valign="top">
<input type="radio" name="balance" value="roundrobin"<?php if($pconfig['balance'] == "roundrobin") echo " CHECKED"; ?> />Round robin
</td>
- <td>
- Each server is used in turns, according to their weights.
- This is the smoothest and fairest algorithm when the server's
- processing time remains equally distributed. This algorithm
- is dynamic, which means that server weights may be adjusted
- on the fly for slow starts for instance.
+ <td class="vncell">
+ Each server is used in turns, according to their weights.
+ This is the smoothest and fairest algorithm when the server's
+ processing time remains equally distributed. This algorithm
+ is dynamic, which means that server weights may be adjusted
+ on the fly for slow starts for instance.
</td>
</tr>
<tr>
- <td width="25%" valign="top">
+ <td class="vncell" width="25%" valign="top">
<input type="radio" name="balance" value="static-rr"<?php if($pconfig['balance'] == "static-rr") echo " CHECKED"; ?> />Static Round Robin
</td>
- <td>
+ <td class="vncell">
Each server is used in turns, according to their weights.
- This algorithm is as similar to roundrobin except that it is
- static, which means that changing a server's weight on the
- fly will have no effect. On the other hand, it has no design
- limitation on the number of servers, and when a server goes
- up, it is always immediately reintroduced into the farm, once
- the full map is recomputed. It also uses slightly less CPU to
- run (around -1%).
+ This algorithm is as similar to roundrobin except that it is
+ static, which means that changing a server's weight on the
+ fly will have no effect. On the other hand, it has no design
+ limitation on the number of servers, and when a server goes
+ up, it is always immediately reintroduced into the farm, once
+ the full map is recomputed. It also uses slightly less CPU to
+ run (around -1%).
</td>
</tr>
<tr>
- <td width="25%" valign="top">
+ <td class="vncell" width="25%" valign="top">
<input type="radio" name="balance" value="leastconn"<?php if($pconfig['balance'] == "leastconn") echo " CHECKED"; ?> />Least Connections
</td>
- <td>
- The server with the lowest number of connections receives the
- connection. Round-robin is performed within groups of servers
- of the same load to ensure that all servers will be used. Use
- of this algorithm is recommended where very long sessions are
- expected, such as LDAP, SQL, TSE, etc... but is not very well
- suited for protocols using short sessions such as HTTP. This
- algorithm is dynamic, which means that server weights may be
- adjusted on the fly for slow starts for instance.
+ <td class="vncell">
+ The server with the lowest number of connections receives the
+ connection. Round-robin is performed within groups of servers
+ of the same load to ensure that all servers will be used. Use
+ of this algorithm is recommended where very long sessions are
+ expected, such as LDAP, SQL, TSE, etc... but is not very well
+ suited for protocols using short sessions such as HTTP. This
+ algorithm is dynamic, which means that server weights may be
+ adjusted on the fly for slow starts for instance.
+ </td>
+ </tr>
+ <tr>
+ <td class="vncell" valign="top">
+ <input type="radio" name="balance" value="source"<?php if($pconfig['balance'] == "source") echo " CHECKED"; ?> />Source
+ </td>
+ <td class="vncell">
+ The source IP address is hashed and divided by the total
+ weight of the running servers to designate which server will
+ receive the request. This ensures that the same client IP
+ address will always reach the same server as long as no
+ server goes down or up. If the hash result changes due to the
+ number of running servers changing, many clients will be
+ directed to a different server. This algorithm is generally
+ used in TCP mode where no cookie may be inserted. It may also
+ be used on the Internet to provide a best-effort stickyness
+ to clients which refuse session cookies. This algorithm is
+ static, which means that changing a server's weight on the
+ fly will have no effect.
</td>
</tr>
- <tr><td valign="top"><input type="radio" name="balance" value="source"<?php if($pconfig['balance'] == "source") echo " CHECKED"; ?> />Source
- </td>
- <td>
- The source IP address is hashed and divided by the total
- weight of the running servers to designate which server will
- receive the request. This ensures that the same client IP
- address will always reach the same server as long as no
- server goes down or up. If the hash result changes due to the
- number of running servers changing, many clients will be
- directed to a different server. This algorithm is generally
- used in TCP mode where no cookie may be inserted. It may also
- be used on the Internet to provide a best-effort stickyness
- to clients which refuse session cookies. This algorithm is
- static, which means that changing a server's weight on the
- fly will have no effect.
+ <tr>
+ <td class="vncell" valign="top">
+ <input type="radio" name="balance" value="uri"<?php if($pconfig['balance'] == "uri") echo " CHECKED"; ?> />Uri (HTTP backends only)
+ </td>
+ <td class="vncell">
+ This algorithm hashes either the left part of the URI (before
+ the question mark) or the whole URI (if the "whole" parameter
+ is present) and divides the hash value by the total weight of
+ the running servers. The result designates which server will
+ receive the request. This ensures that the same URI will
+ always be directed to the same server as long as no server
+ goes up or down. This is used with proxy caches and
+ anti-virus proxies in order to maximize the cache hit rate.
+ Note that this algorithm may only be used in an HTTP backend.<br/>
+ <input name="balance_urilen" size="10" value="<?=$pconfig['balance_urilen']?>" />Len (optional) <br/>
+ The "len" parameter
+ indicates that the algorithm should only consider that many
+ characters at the beginning of the URI to compute the hash.<br/>
+ <input name="balance_uridepth" size="10" value="<?=$pconfig['balance_uridepth']?>" />Depth (optional) <br/>
+ The "depth" parameter indicates the maximum directory depth
+ to be used to compute the hash. One level is counted for each
+ slash in the request.<br/>
+ <input id="balance_uriwhole" name="balance_uriwhole" type="checkbox" value="yes" <?php if ($pconfig['balance_uriwhole']=='yes') echo "checked"; ?> />
+ Allow using whole URI including url parameters behind a question mark.
</td>
</tr>
+ <!-- TODO add some other balance methods -->
</table>
</td>
</tr>
@@ -868,7 +899,7 @@ set by the 'retries' parameter.</div>
</td>
</tr>
<tr><td>&nbsp;</td></tr>
- <? if (haproxy_verion() >= '1.6' ) { ?>
+ <? if (haproxy_version() >= '1.6' ) { ?>
<tr>
<td colspan="2" valign="top" class="listtopic">Email notifications</td>
</tr>
@@ -985,7 +1016,7 @@ set by the 'retries' parameter.</div>
<br/>
<br/>
<?
- haproxy_htmllist("table_errorfile", $a_errorfiles, $fields_errorfile);
+ $errorfileslist->Draw($a_errorfiles);
?>
</td>
</tr>
@@ -1030,16 +1061,17 @@ set by the 'retries' parameter.</div>
<br/>
<script type="text/javascript">
<?
- phparray_to_javascriptarray($fields_servers,"fields_servers",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
phparray_to_javascriptarray($fields_servers_details,"fields_details_servers",Array('/*','/*/name','/*/type'));
- phparray_to_javascriptarray($fields_errorfile,"fields_errorfile",Array('/*','/*/name','/*/type','/*/size','/*/items','/*/items/*','/*/items/*/*','/*/items/*/*/name'));
phparray_to_javascriptarray($a_checktypes,"checktypes",Array('/*','/*/name','/*/descr'));
phparray_to_javascriptarray($a_cookiemode,"cookiemode",Array('/*','/*/name','/*/descr'));
phparray_to_javascriptarray($a_sticky_type,"sticky_type",Array('/*','/*/descr','/*/cookiedescr'));
- phparray_to_javascriptarray($a_files,"a_files",Array('/*','/*/name','/*/descr'));
+ //phparray_to_javascriptarray($a_files,"a_files",Array('/*','/*/name','/*/descr'));
+
+ $serverslist->outputjavascript();
+ $errorfileslist->outputjavascript();
?>
browser_InnerText_support = (document.getElementsByTagName("body")[0].innerText != undefined) ? true : false;
-
+
totalrows = <?php echo $counter; ?>;
updatevisibility();
</script>
diff --git a/config/haproxy-devel/www/haproxy_pools.php b/config/haproxy-devel/www/haproxy_pools.php
index 92235933..deaeb46e 100644
--- a/config/haproxy-devel/www/haproxy_pools.php
+++ b/config/haproxy-devel/www/haproxy_pools.php
@@ -65,19 +65,13 @@ if ($_GET['act'] == "del") {
exit;
}
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version < 2.0)
- $one_two = true;
-
$pgtitle = "Services: HAProxy: Backend server pools";
include("head.inc");
+haproxy_css();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
<form action="haproxy_pools.php" method="post">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
diff --git a/config/haproxy-devel/www/haproxy_stats.php b/config/haproxy-devel/www/haproxy_stats.php
index 302793b6..628d0e5a 100644
--- a/config/haproxy-devel/www/haproxy_stats.php
+++ b/config/haproxy-devel/www/haproxy_stats.php
@@ -68,7 +68,7 @@ if (isset($_GET['haproxystats']) || isset($_GET['scope']) || (isset($_POST) && i
exit(0);
}
require_once("guiconfig.inc");
-if (isset($_GET['showsticktablecontent'])){
+if (isset($_GET['showsticktablecontent']) || isset($_GET['showstatresolvers'])) {
if (is_numeric($pconfig['localstats_sticktable_refreshtime']))
header("Refresh: {$pconfig['localstats_sticktable_refreshtime']}");
}
@@ -91,10 +91,6 @@ if ($_POST) {
}
}
-$pf_version=substr(trim(file_get_contents("/etc/version")),0,3);
-if ($pf_version < 2.0)
- $one_two = true;
-
$pgtitle = "Services: HAProxy: Stats";
include("head.inc");
@@ -102,9 +98,6 @@ include("head.inc");
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<form action="haproxy_stats.php" method="post">
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (file_exists($d_haproxyconfdirty_path)): ?>
@@ -123,15 +116,25 @@ include("head.inc");
<table class="tabcont" width="100%" height="100%" cellspacing="0">
<tr>
<?
-if (isset($_GET['showsticktablecontent'])){
+
+if (isset($_GET['showstatresolvers'])){
+ $showstatresolversname = $_GET['showstatresolvers'];
+ echo "<td colspan='2'>";
+ echo "Contents of the sticktable: $sticktablename<br/>";
+ $res = haproxy_socket_command("show stat resolvers $showstatresolversname");
+ foreach($res as $line){
+ echo "<br/>".print_r($line,true);
+ }
+ echo "</td>";
+} elseif (isset($_GET['showsticktablecontent'])){
$sticktablename = $_GET['showsticktablecontent'];
-echo "<td colspan='2'>";
+ echo "<td colspan='2'>";
echo "Contents of the sticktable: $sticktablename<br/>";
$res = haproxy_socket_command("show table $sticktablename");
foreach($res as $line){
echo "<br/>".print_r($line,true);
}
-echo "</td>";
+ echo "</td>";
} else {
?>
<td colspan="2">
@@ -177,6 +180,15 @@ echo "</td>";
<td>&nbsp;</td>
</tr>
<tr>
+ <td colspan="2" valign="top" class="listtopic">HAProxy DNS</td>
+ </tr>
+ <tr>
+ <td colspan="2" valign="top" class="vncell"><a href="/haproxy_stats.php?showstatresolvers=globalresolvers" target="_blank">DNS statistics</a></td>
+ </tr>
+ <tr>
+ <td>&nbsp;</td>
+ </tr>
+ <tr>
<td colspan="2" valign="top" class="listtopic">HAProxy stats</td>
</tr>
<tr>
diff --git a/config/haproxy-devel/www/haproxy_templates.php b/config/haproxy-devel/www/haproxy_templates.php
index 478c83a3..71135b14 100644
--- a/config/haproxy-devel/www/haproxy_templates.php
+++ b/config/haproxy-devel/www/haproxy_templates.php
@@ -145,14 +145,12 @@ if ($_POST) {
$pgtitle = "Services: HAProxy: Templates";
include("head.inc");
+haproxy_css();
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
<form action="haproxy_templates.php" method="post">
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (file_exists($d_haproxyconfdirty_path)): ?>