Copyright (C) 2008 Remco Hoef All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ require("guiconfig.inc"); $d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty"; if (!is_array($config['installedpackages']['haproxy']['ha_servers']['item'])) { $config['installedpackages']['haproxy']['ha_servers']['item'] = array(); } $a_server = &$config['installedpackages']['haproxy']['ha_servers']['item']; if (isset($_POST['id'])) $id = $_POST['id']; else $id = $_GET['id']; if (isset($id) && $a_server[$id]) { $pconfig['name'] = $a_server[$id]['name']; $pconfig['address'] = $a_server[$id]['address']; $pconfig['port'] = $a_server[$id]['port']; $pconfig['backend'] = $a_server[$id]['backend']; $pconfig['weight'] = $a_server[$id]['weight']; $pconfig['cookie'] = $a_server[$id]['cookie']; $pconfig['status'] = $a_server[$id]['status']; } $changedesc = "Services: HAProxy: Servers: "; $changecount = 0; if ($_POST) { $changecount++; unset($input_errors); $pconfig = $_POST; $reqdfields = explode(" ", "name address port backend weight"); $reqdfieldsn = explode(",", "Name,Address,Port,Backend,Weight"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['name'])) $input_errors[] = "The field 'Name' contains invalid characters."; if (preg_match("/[^a-zA-Z0-9\.]/", $_POST['address'])) $input_errors[] = "The field 'Address' contains invalid characters."; if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['cookie'])) $input_errors[] = "The field 'Cookie' contains invalid characters."; if (!is_numeric($_POST['port'])) $input_errors[] = "The field 'Port' value is not a number."; else { if (!($_POST['port']>=1 && $_POST['port']<=65535)) $input_errors[] = "The field 'Port' value must be between 1 and 65535."; } if (!is_numeric($_POST['weight'])) $input_errors[] = "The field 'Weight' value is not a number."; else { if (!($_POST['weight']>=1 && $_POST['weight']<=256)) $input_errors[] = "The field 'Weight' value must be between 1 and 256."; } /* Ensure that our pool names are unique */ for ($i=0; isset($config['installedpackages']['haproxy']['ha_servers']['item'][$i]); $i++) if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_servers']['item'][$i]['name']) && ($i != $id)) $input_errors[] = "This server name has already been used. Server names must be unique."; if (!$input_errors) { $server = array(); if(isset($id) && $a_server[$id]) $server = $a_server[$id]; if($server['name'] != "") $changedesc .= " modified '{$server['name']}' pool:"; update_if_changed("name", $server['name'], $_POST['name']); update_if_changed("address", $server['address'], $_POST['address']); update_if_changed("port", $server['port'], $_POST['port']); update_if_changed("backend", $server['backend'], $_POST['backend']); update_if_changed("cookie", $server['cookie'], $_POST['cookie']); update_if_changed("weight", $server['weight'], $_POST['weight']); update_if_changed("status", $server['status'], $_POST['status']); if (isset($id) && $a_server[$id]) { $a_server[$id] = $server; } else { $a_server[] = $server; } if ($changecount > 0) { touch($d_haproxyconfdirty_path); write_config($changedesc); /* echo "
";
			print_r($config);
			echo "
"; */ } header("Location: haproxy_servers.php"); exit; } } $pfSversion = str_replace("\n", "", file_get_contents("/etc/version")); if(strstr($pfSversion, "1.2")) $one_two = true; $pgtitle = "HAProxy: Server: Edit"; include("head.inc"); ?>

Edit haproxy server
Name size="16" maxlength="16">
Address size="64">
Port size="5">
Backend
Status
Cookie size="64">
This value will be checked in incoming requests, and the first operational server possessing the same value will be selected. In return, in cookie insertion or rewrite modes, this value will be assigned to the cookie sent to the client. There is nothing wrong in having several servers sharing the same cookie value, and it is in fact somewhat common between normal and backup servers. See also the "cookie" keyword in backend section.
Weight size="64">
The default weight is 1, and the maximal value is 255.
NOTE: If this parameter is used to distribute the load according to server's capacity, it is recommended to start with values which can both grow and shrink, for instance between 10 and 100 to leave enough room above and below for later adjustments.