From 6a7987846c7d4680a35264f7e27287c61937cf78 Mon Sep 17 00:00:00 2001 From: thompsa Date: Sun, 7 Feb 2010 16:21:47 +1300 Subject: Make some of the gui changes as described. --- config/haproxy-dev/haproxy.inc | 32 ++- config/haproxy-dev/haproxy_frontends.php | 14 +- config/haproxy-dev/haproxy_frontends_edit.php | 281 +++++++++++++++----------- config/haproxy-dev/haproxy_global.php | 4 +- config/haproxy-dev/haproxy_servers.php | 8 +- 5 files changed, 200 insertions(+), 139 deletions(-) (limited to 'config') diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc index 536ef1f7..2d7b671f 100644 --- a/config/haproxy-dev/haproxy.inc +++ b/config/haproxy-dev/haproxy.inc @@ -214,12 +214,36 @@ function haproxy_configure() { fwrite ($fd, "\tstats\t\t\tauth " . $backend['stats_username'].":". $backend['stats_password']."\n"); } - $a_acl=&$frontend['ha_acls']['item']; + $a_acl=&$backend['ha_acls']['item']; if(!is_array($a_acl)) $a_acl=array(); - foreach ($a_acl as $acl) - fwrite ($fd, "\tacl\t\t\t".$acl['name']."\t\t".$acl['expression']."\n"); + foreach ($a_acl as $acl) { + if ($acl['expression'] == "host_starts_with") + $expr = 'hdr_beg(host) -i'; + else if ($acl['expression'] == "host_ends_with") + $expr = 'hdr_end(host) -i'; + else if ($acl['expression'] == "host_matches") + $expr = 'hdr(host) -i'; + else if ($acl['expression'] == "host_regex") + $expr = 'hdr_reg(host) -i'; + else if ($acl['expression'] == "host_contains") + $expr = 'hdr_dir(host) -i'; + else if ($acl['expression'] == "path_starts_with") + $expr = 'path_beg -i'; + else if ($acl['expression'] == "path_ends_with") + $expr = 'path_end -i'; + else if ($acl['expression'] == "path_matches") + $expr = 'path -i'; + else if ($acl['expression'] == "path_regex") + $expr = 'path_reg -i'; + else if ($acl['expression'] == "path_contains") + $expr = 'path_dir -i'; + else if ($acl['expression'] == "source_ip") + $expr = 'src'; + $expr .= " " . $acl['value']; + fwrite ($fd, "\tacl\t\t\t".$acl['name']."\t".$expr."\n"); + } $server['backend'] .= " "; if(is_array($a_servers)) { @@ -417,4 +441,4 @@ function haproxy_do_xmlrpc_sync($sync_to_ip, $password) { } } -?> \ No newline at end of file +?> diff --git a/config/haproxy-dev/haproxy_frontends.php b/config/haproxy-dev/haproxy_frontends.php index d50133b8..87efb87f 100755 --- a/config/haproxy-dev/haproxy_frontends.php +++ b/config/haproxy-dev/haproxy_frontends.php @@ -69,7 +69,7 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); if(strstr($pfSversion, "1.2")) $one_two = true; -$pgtitle = "Services: HAProxy: Frontend"; +$pgtitle = "Services: HAProxy: Listener"; include("head.inc"); ?> @@ -89,10 +89,10 @@ include("head.inc"); @@ -102,7 +102,6 @@ include("head.inc"); Name Description - Stats URI Type @@ -114,9 +113,6 @@ include("head.inc"); - - - diff --git a/config/haproxy-dev/haproxy_frontends_edit.php b/config/haproxy-dev/haproxy_frontends_edit.php index 7f6562ad..c60415e3 100755 --- a/config/haproxy-dev/haproxy_frontends_edit.php +++ b/config/haproxy-dev/haproxy_frontends_edit.php @@ -39,6 +39,19 @@ if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) { $a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item']; +$a_expr = array(); +$a_expr[] = array("host_starts_with", "Host starts with:", "HTTP"); +$a_expr[] = array("host_ends_with", "Host ends with:", "HTTP"); +$a_expr[] = array("host_matches", "Host matches:", "HTTP"); +$a_expr[] = array("host_regex", "Host regex:", "HTTP"); +$a_expr[] = array("host_contains", "Host contains:", "HTTP"); +$a_expr[] = array("path_starts_with", "Path starts with:", "HTTP"); +$a_expr[] = array("path_ends_with", "Path ends with:", "HTTP"); +$a_expr[] = array("path_matches", "Path matches:", "HTTP"); +$a_expr[] = array("path_regex", "Path regex:", "HTTP"); +$a_expr[] = array("path_contains", "Path contains:", "HTTP"); +$a_expr[] = array("source_up", "Source IP:", ""); + if (isset($_POST['id'])) $id = $_POST['id']; else @@ -47,13 +60,13 @@ else if (isset($id) && $a_backend[$id]) { $pconfig['name'] = $a_backend[$id]['name']; $pconfig['desc'] = $a_backend[$id]['desc']; + $pconfig['status'] = $a_backend[$id]['status']; $pconfig['connection_timeout'] = $a_backend[$id]['connection_timeout']; $pconfig['server_timeout'] = $a_backend[$id]['server_timeout']; $pconfig['retries'] = $a_backend[$id]['retries']; $pconfig['type'] = $a_backend[$id]['type']; $pconfig['balance'] = $a_backend[$id]['balance']; - $pconfig['monitor_uri'] = $a_backend[$id]['monitor_uri']; $pconfig['forwardfor'] = $a_backend[$id]['forwardfor']; $pconfig['httpclose'] = $a_backend[$id]['httpclose']; @@ -74,7 +87,7 @@ if (isset($id) && $a_backend[$id]) { } -$changedesc = "Services: HAProxy: Frontend"; +$changedesc = "Services: HAProxy: Listener"; $changecount = 0; if ($_POST) { @@ -87,7 +100,7 @@ if ($_POST) { $reqdfields = explode(" ", "name connection_timeout server_timeout stats_username stats_password stats_uri stats_realm"); $reqdfieldsn = explode(",", "Name,Connection timeout,Server timeout,Stats Username,Stats Password,Stats Uri,Stats Realm"); } else { - $reqdfields = explode(" ", "name connection_timeout server_timeout monitor_uri"); + $reqdfields = explode(" ", "name connection_timeout server_timeout"); $reqdfieldsn = explode(",", "Name,Connection timeout,Server timeout,Monitor Uri"); } @@ -137,6 +150,7 @@ if ($_POST) { for($x=0; $x<99; $x++) { $acl_name=$_POST['acl_name'.$x]; $acl_expression=$_POST['acl_expression'.$x]; + $acl_value=$_POST['acl_value'.$x]; if ($acl_name) { // check for duplicates @@ -149,13 +163,14 @@ if ($_POST) { $acl=array(); $acl['name']=$acl_name; $acl['expression']=$acl_expression; + $acl['value']=$acl_value; $a_acl[]=$acl; if (preg_match("/[^a-zA-Z0-9\.\-_]/", $acl_name)) $input_errors[] = "The field 'Name' contains invalid characters."; - if (!preg_match("/.{2,}/", $acl_expression)) - $input_errors[] = "The field 'Expression' is required."; + if (!preg_match("/.{2,}/", $acl_value)) + $input_errors[] = "The field 'Value' is required."; if (!preg_match("/.{2,}/", $acl_name)) $input_errors[] = "The field 'Name' is required."; @@ -213,13 +228,13 @@ if ($_POST) { update_if_changed("name", $backend['name'], $_POST['name']); update_if_changed("description", $backend['desc'], $_POST['desc']); + update_if_changed("status", $backend['status'], $_POST['status']); update_if_changed("connection_timeout", $backend['connection_timeout'], $_POST['connection_timeout']); update_if_changed("server_timeout", $backend['server_timeout'], $_POST['server_timeout']); update_if_changed("retries", $backend['retries'], $_POST['retries']); update_if_changed("type", $backend['type'], $_POST['type']); update_if_changed("balance", $backend['balance'], $_POST['balance']); update_if_changed("cookie_name", $backend['cookie_name'], $_POST['cookie_name']); - update_if_changed("monitor_uri", $backend['monitor_uri'], $_POST['monitor_uri']); update_if_changed("forwardfor", $backend['forwardfor'], $_POST['forwardfor']); update_if_changed("httpclose", $backend['httpclose'], $_POST['httpclose']); update_if_changed("stats_enabled", $backend['stats_enabled'], $_POST['stats_enabled']); @@ -256,7 +271,7 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); if(strstr($pfSversion, "1.2")) $one_two = true; -$pgtitle = "HAProxy: Frontend: Edit"; +$pgtitle = "HAProxy: Listener: Edit"; include("head.inc"); ?> @@ -293,7 +308,7 @@ include("head.inc"); if(rowtype[i] == 'textbox') { td.innerHTML=" "; } else if(rowtype[i] == 'select') { - td.innerHTML=" "; + td.innerHTML=" "; } else { td.innerHTML=" "; } @@ -335,15 +350,15 @@ include("head.inc"); rowname[0] = "acl_name"; rowtype[0] = "textbox"; - rowsize[0] = "30"; + rowsize[0] = "20"; rowname[1] = "acl_expression"; - rowtype[1] = "textbox"; - rowsize[1] = "35"; + rowtype[1] = "select"; + rowsize[1] = "10"; - rowname[2] = "acl_backend"; - rowtype[2] = "select"; - rowsize[2] = "10"; + rowname[2] = "acl_value"; + rowtype[2] = "textbox"; + rowsize[2] = "35"; function toggle_stats() { var stats_enabled=document.getElementById('stats_enabled'); @@ -373,9 +388,9 @@ include("head.inc"); - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Edit haproxy backend
Edit haproxy listener
Name size="25" maxlength="25"> @@ -387,6 +402,135 @@ include("head.inc"); size="64">
Status + +
External address + +
+ + If you want this rule to apply to another IP address than the IP address of the interface chosen above, + select it here (you need to define Virtual IP addresses on the first). + Also note that if you are trying to redirect connections on the LAN select the "any" option. + +
External port + size="10" maxlength="10"> +
The port to listen to. To specify multiple ports, separate with a comma (,). EXAMPLE: 80,443
+
Server pool + +
Server Port + size="10" maxlength="10"> +
The default server port.
+
Type + +
Access Control lists + + + + + + + + + + + + + + + +
NameExpressionValue
+ +
+ + +
+ For more information about ACL's please see HAProxy Documentation Section 7 - Using ACL's +
+ + + + - - - - - - - - - - - - - - - - - - - - -*/ ?> diff --git a/config/haproxy-dev/haproxy_global.php b/config/haproxy-dev/haproxy_global.php index e547aa10..dddb0413 100755 --- a/config/haproxy-dev/haproxy_global.php +++ b/config/haproxy-dev/haproxy_global.php @@ -133,8 +133,8 @@ function enable_change(enable_change) { /* active tabs */ $tab_array = array(); $tab_array[] = array("Settings", true, "haproxy_global.php"); - $tab_array[] = array("Frontends", false, "haproxy_frontends.php"); - $tab_array[] = array("Servers", false, "haproxy_servers.php"); + $tab_array[] = array("Listener", false, "haproxy_frontends.php"); + $tab_array[] = array("Server Pool", false, "haproxy_servers.php"); display_top_tabs($tab_array); ?> diff --git a/config/haproxy-dev/haproxy_servers.php b/config/haproxy-dev/haproxy_servers.php index cacf995a..4a0b08c9 100755 --- a/config/haproxy-dev/haproxy_servers.php +++ b/config/haproxy-dev/haproxy_servers.php @@ -90,10 +90,10 @@ include("head.inc"); -- cgit v1.2.3
Advanced settings
Connection timeout @@ -411,17 +555,6 @@ want the clients to see the failures. The number of attempts to reconnect is set by the 'retries' parameter (2).
Type - -
Balance @@ -491,48 +624,6 @@ set by the 'retries' parameter (2).
Monitor Uri - size="50" maxlength="50"> -
- Example: / or /index.php or /index.html or /testmypage.cgi -
Port - size="10" maxlength="10"> -
The port to listen to. To specify multiple ports, separate with a comma (,). EXAMPLE: 80,443
-
External address - -
- - If you want this rule to apply to another IP address than the IP address of the interface chosen above, - select it here (you need to define Virtual IP addresses on the first). - Also note that if you are trying to redirect connections on the LAN select the "any" option. - -
Max connections @@ -547,56 +638,6 @@ set by the 'retries' parameter (2).
Access Control lists - - - - - - - - - - - - - - - -
NameExpressionBackend
- -
- - -
- Fore more information about ACL's please see HAProxy Documentation Section 7 - Using ACL's -
Use 'forwardfor' option