aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/haproxy/haproxy.inc29
-rw-r--r--config/haproxy/haproxy.xml6
-rwxr-xr-xconfig/haproxy/haproxy_frontends.php (renamed from config/haproxy/haproxy_backends.php)12
-rwxr-xr-xconfig/haproxy/haproxy_frontends_edit.php (renamed from config/haproxy/haproxy_backends_edit.php)11
-rwxr-xr-xconfig/haproxy/haproxy_global.php2
-rwxr-xr-xconfig/haproxy/haproxy_servers.php4
-rwxr-xr-xconfig/haproxy/haproxy_servers_edit.php216
7 files changed, 225 insertions, 55 deletions
diff --git a/config/haproxy/haproxy.inc b/config/haproxy/haproxy.inc
index 11fd3782..0dcacab3 100644
--- a/config/haproxy/haproxy.inc
+++ b/config/haproxy/haproxy.inc
@@ -147,7 +147,14 @@ function haproxy_configure() {
fwrite ($fd, "{$backendinfo}");
fwrite ($fd, "{$listenip}");
- fwrite ($fd, "\tmode\t\t\t".$backend['type'] . "\n");
+
+ // https is an alias for tcp for clarity purpouses
+ if($backend['type'] == "https")
+ $backend = "tcp";
+ else
+ $backend = $backend['type'];
+
+ fwrite ($fd, "\tmode\t\t\t" . $backend . "\n");
fwrite ($fd, "\tlog\t\t\tglobal\n");
fwrite ($fd, "\toption\t\t\tdontlognull\n");
fwrite ($fd, "\toption\t\t\thttpclose\n");
@@ -197,15 +204,21 @@ function haproxy_configure() {
foreach ($a_acl as $acl)
fwrite ($fd, "\tacl\t\t\t".$acl['name']."\t\t".$acl['expression']."\n");
+ $server['backend'] .= " ";
if(is_array($a_servers)) {
foreach ($a_servers as $server) {
- if($server['backend']==$backend['name']) {
- if($server['status']=='active') {
- if($server['cookie'])
- $cookie = " cookie {$server['cookie']} ";
- else
- $cookie = "";
- fwrite ($fd, "\tserver\t\t\t".$server['name']." ".$server['address'].":".$server['port']." $cookie "." check inter 1000 weight ".$server['weight']."\n");
+ $backends_to_process = split(" ", $server['backend']);
+ foreach($backends_to_process as $backend) {
+ if($backend == "")
+ continue;
+ if($backend ==$backend['name']) {
+ if($server['status']=='active') {
+ if($server['cookie'])
+ $cookie = " cookie {$server['cookie']} ";
+ else
+ $cookie = "";
+ fwrite ($fd, "\tserver\t\t\t".$server['name']." ".$server['address'].":".$server['port']." $cookie "." check inter 1000 weight ".$server['weight']."\n");
+ }
}
}
}
diff --git a/config/haproxy/haproxy.xml b/config/haproxy/haproxy.xml
index 6128f1ac..abfee4b6 100644
--- a/config/haproxy/haproxy.xml
+++ b/config/haproxy/haproxy.xml
@@ -50,7 +50,7 @@
<name>HAProxy</name>
<tooltiptext></tooltiptext>
<section>Services</section>
- <url>/haproxy_backends.php</url>
+ <url>/haproxy_frontends.php</url>
</menu>
<service>
<name>HAProxy</name>
@@ -67,12 +67,12 @@
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy/haproxy_backends.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy/haproxy_frontends.php</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy/haproxy_backends_edit.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy/haproxy_frontends_edit.php</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
diff --git a/config/haproxy/haproxy_backends.php b/config/haproxy/haproxy_frontends.php
index dacb9f35..1dcc0483 100755
--- a/config/haproxy/haproxy_backends.php
+++ b/config/haproxy/haproxy_frontends.php
@@ -59,7 +59,7 @@ if ($_GET['act'] == "del") {
unset($a_backend[$_GET['id']]);
write_config();
touch($d_haproxyconfdirty_path);
- header("Location: haproxy_backends.php");
+ header("Location: haproxy_frontends.php");
exit;
}
}
@@ -69,13 +69,13 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
-$pgtitle = "Services: HAProxy: Backends";
+$pgtitle = "Services: HAProxy: Frontend";
include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<form action="haproxy_backends.php" method="post">
+<form action="haproxy_frontends.php" method="post">
<?php if($one_two): ?>
<p class="pgtitle"><?=$pgtitle?></p>
<?php endif; ?>
@@ -90,7 +90,7 @@ include("head.inc");
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontends/Backends", true, "haproxy_backends.php");
+ $tab_array[] = array("Frontends", true, "haproxy_frontends.php");
$tab_array[] = array("Servers", false, "haproxy_servers.php");
display_top_tabs($tab_array);
?>
@@ -123,8 +123,8 @@ include("head.inc");
<td class="list" nowrap>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="haproxy_backends_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="haproxy_backends.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_frontends_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_frontends.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
</td>
diff --git a/config/haproxy/haproxy_backends_edit.php b/config/haproxy/haproxy_frontends_edit.php
index eb2e6c77..e169b25e 100755
--- a/config/haproxy/haproxy_backends_edit.php
+++ b/config/haproxy/haproxy_frontends_edit.php
@@ -75,7 +75,7 @@ if (isset($id) && $a_backend[$id]) {
}
-$changedesc = "Services: HAProxy: Backends";
+$changedesc = "Services: HAProxy: Frontend";
$changecount = 0;
if ($_POST) {
@@ -131,7 +131,7 @@ if ($_POST) {
/* Ensure that our pool names are unique */
for ($i=0; isset($config['installedpackages']['haproxy']['ha_backends']['item'][$i]); $i++)
if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_backends']['item'][$i]['name']) && ($i != $id))
- $input_errors[] = "This backend name has already been used. Backend names must be unique.";
+ $input_errors[] = "This backend name has already been used. Frontend names must be unique.";
$a_acl=array();
$acl_names=array();
@@ -245,7 +245,7 @@ if ($_POST) {
write_config($changedesc);
}
- header("Location: haproxy_backends.php");
+ header("Location: haproxy_frontends.php");
exit;
}
}
@@ -254,7 +254,7 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
-$pgtitle = "HAProxy: Backend: Edit";
+$pgtitle = "HAProxy: Frontend: Edit";
include("head.inc");
?>
@@ -414,6 +414,7 @@ set by the 'retries' parameter (2).</div>
<td width="78%" class="vtable" colspan="2">
<select name="type" id="type" onchange="type_change();">
<option value="http"<?php if($pconfig['type'] == "http") echo " SELECTED"; ?>>HTTP</option>
+ <option value="https"<?php if($pconfig['type'] == "https") echo " SELECTED"; ?>>HTTPS</option>
<option value="tcp"<?php if($pconfig['type'] == "tcp") echo " SELECTED"; ?>>TCP</option>
<option value="health"<?php if($pconfig['type'] == "health") echo " SELECTED"; ?>>Health</option>
</select>
@@ -607,7 +608,7 @@ set by the 'retries' parameter (2).</div>
<tr>
<br/>&nbsp;<br/>
<td colspan='3'>
- <span class="vexpl"><b>NOTE:</b> You must add a firewall rule permitting access to this backend!</span>
+ <span class="vexpl"><b>NOTE:</b> You must add a firewall rule permitting access to this frontend!</span>
</td>
</tr>
</table>
diff --git a/config/haproxy/haproxy_global.php b/config/haproxy/haproxy_global.php
index e5f37cb5..20dc47a2 100755
--- a/config/haproxy/haproxy_global.php
+++ b/config/haproxy/haproxy_global.php
@@ -125,7 +125,7 @@ function enable_change(enable_change) {
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", true, "haproxy_global.php");
- $tab_array[] = array("Frontends/Backends", false, "haproxy_backends.php");
+ $tab_array[] = array("Frontends", false, "haproxy_frontends.php");
$tab_array[] = array("Servers", false, "haproxy_servers.php");
display_top_tabs($tab_array);
?>
diff --git a/config/haproxy/haproxy_servers.php b/config/haproxy/haproxy_servers.php
index 4dffadca..3bf4eac2 100755
--- a/config/haproxy/haproxy_servers.php
+++ b/config/haproxy/haproxy_servers.php
@@ -68,7 +68,7 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
-$pgtitle = "Services: HAProxy: Backends";
+$pgtitle = "Services: HAProxy: Servers";
include("head.inc");
?>
@@ -89,7 +89,7 @@ include("head.inc");
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Frontends/Backends", false, "haproxy_backends.php");
+ $tab_array[] = array("Frontends", false, "haproxy_frontends.php");
$tab_array[] = array("Servers", true, "haproxy_servers.php");
display_top_tabs($tab_array);
?>
diff --git a/config/haproxy/haproxy_servers_edit.php b/config/haproxy/haproxy_servers_edit.php
index b2053f4a..a265353d 100755
--- a/config/haproxy/haproxy_servers_edit.php
+++ b/config/haproxy/haproxy_servers_edit.php
@@ -32,6 +32,7 @@
require("guiconfig.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
+$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
if (!is_array($config['installedpackages']['haproxy']['ha_servers']['item'])) {
$config['installedpackages']['haproxy']['ha_servers']['item'] = array();
@@ -63,8 +64,8 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
- $reqdfields = explode(" ", "name address port backend weight");
- $reqdfieldsn = explode(",", "Name,Address,Port,Backend,Weight");
+ $reqdfields = explode(" ", "name address port weight");
+ $reqdfieldsn = explode(",", "Name,Address,Port,Weight");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
@@ -96,6 +97,15 @@ if ($_POST) {
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.";
+ $backend = "";
+ for($x=0; $x<299; $x++) {
+ $comd = "\$backends = \$_POST['backend" . $x . "'];";
+ eval($comd);
+ if($backends)
+ $backend .= "$backends ";
+ }
+ $backend = trim($backend);
+
if (!$input_errors) {
$server = array();
if(isset($id) && $a_server[$id])
@@ -103,14 +113,14 @@ if ($_POST) {
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("backend", $server['backend'], $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']);
+ update_if_changed("address", $server['address'], $_POST['address']);
if (isset($id) && $a_server[$id]) {
$a_server[$id] = $server;
@@ -140,8 +150,12 @@ if(strstr($pfSversion, "1.2"))
$pgtitle = "HAProxy: Server: Edit";
include("head.inc");
+row_helper();
+
?>
+<input type='hidden' name='address_type' value='textbox' />
+
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<script type="text/javascript" language="javascript" src="pool.js"></script>
@@ -153,7 +167,11 @@ function clearcombo(){
document.iform.serversSelect.selectedIndex = -1;
}
</script>
-
+<script type="text/javascript">
+ rowname[0] = "backend";
+ rowtype[0] = "select";
+ rowsize[0] = "1";
+</script>
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if($one_two): ?>
@@ -162,7 +180,7 @@ function clearcombo(){
<form action="haproxy_servers_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" valign="top" class="listtopic">Edit haproxy server</td>
+ <td colspan="2" valign="top" class="listtopic">Edit HAProxy server</td>
</tr>
<tr align="left">
<td width="22%" valign="top" class="vncellreq">Name</td>
@@ -171,10 +189,68 @@ function clearcombo(){
</td>
</tr>
<tr align="left">
- <td width="22%" valign="top" class="vncellreq">Address</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="address" type="text" <?if(isset($pconfig['address'])) echo "value=\"{$pconfig['address']}\"";?> size="64">
- </td>
+ <td width="22%" valign="top" class="vncellreq">Frontend(s)</td>
+ <td width="78%" class="vtable">
+ <table id="frontendtable">
+ <tbody>
+ <tr>
+ <td><div id="onecolumn"></div></td>
+ </tr>
+ <?php
+ $counter = 0;
+ $tracker = 0;
+ $backend = $pconfig['backend'];
+ $item = explode(" ", $backend);
+ foreach($item as $ww) {
+ $address = $ww;
+ if($counter > 0)
+ $tracker = $counter + 1;
+ ?>
+ <tr>
+ <td>
+ <select name="backend<?php echo $tracker; ?>">
+ <?php
+ $i = 0;
+ if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
+ }
+ $backends = split(" ", $pconfig['backend']);
+ foreach($backends as $be)
+ foreach ($a_backend as $backend) {
+ ?>
+ <option value="<?=$backend['name'];?>" <?php if($backend['name']==$be) echo "SELECTED";?>><?=$backend['name'];?></option>
+ <?php } ?>
+ </select>
+ </td>
+ <td>
+ <?php
+ if($counter > 0)
+ echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
+ ?>
+ </td>
+ </tr>
+ <?php
+ $counter++;
+ } // end foreach
+ ?>
+ </tbody>
+ <tfoot>
+ </tfoot>
+ </table>
+ <a onclick="javascript:addRowTo('frontendtable'); return false;" href="#">
+ <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
+ </a>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vncellreq">
+ <div id="addressnetworkport">
+ IP Address
+ </div>
+ </td>
+ <td width="78%" class="vtable">
+ <input name="address" type="text" id="address" size="30" value="<?=htmlspecialchars($pconfig['address']);?>" />
+ </td>
</tr>
<tr align="left">
<td width="22%" valign="top" class="vncellreq">Port</td>
@@ -183,25 +259,6 @@ function clearcombo(){
</td>
</tr>
<tr align="left">
- <td width="22%" valign="top" class="vncellreq">Backend</td>
- <td width="78%" class="vtable" colspan="2">
- <select name="backend">
- <?php
- $i = 0;
- if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
- $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
- }
- $a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
-
- foreach ($a_backend as $backend) {
- ?>
- <option value="<?=$backend['name'];?>" <?php if($backend['name']==$pconfig['backend']) echo "SELECTED";?>><?=$backend['name'];?></option>
- <?php } ?>
- </select>
- <div></div>
- </td>
- </tr>
- <tr align="left">
<td width="22%" valign="top" class="vncellreq">Status</td>
<td width="78%" class="vtable" colspan="2">
<select name="status">
@@ -249,5 +306,104 @@ function clearcombo(){
</form>
<br>
<?php include("fend.inc"); ?>
+<script type="text/javascript">
+ field_counter_js = 1;
+ rows = 1;
+ totalrows = <?php echo $counter; ?>;
+ loaded = <?php echo $counter; ?>;
+</script>
</body>
</html>
+
+<?php
+
+function row_helper() {
+ global $pconfig, $a_backend;
+ $options = "";
+ foreach ($a_backend as $backend) {
+ $options .= "<option value='{$backend['name']}'";
+ if($backend['name'] == $pconfig['backend'])
+ $options .= "SELECTED";
+ $options .= ">";
+ $options .= $backend['name'];
+ $options .= "</option>";
+ }
+
+ echo <<<EOF
+<script type="text/javascript">
+// Global Variables
+var rowname = new Array(99);
+var rowtype = new Array(99);
+var newrow = new Array(99);
+var rowsize = new Array(99);
+
+for (i = 0; i < 99; i++) {
+ rowname[i] = '';
+ rowtype[i] = '';
+ newrow[i] = '';
+ rowsize[i] = '25';
+}
+
+var field_counter_js = 0;
+var loaded = 0;
+var is_streaming_progress_bar = 0;
+var temp_streaming_text = "";
+
+var addRowTo = (function() {
+ return (function (tableId) {
+ var d, tbody, tr, td, bgc, i, ii, j;
+ d = document;
+ tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
+ tr = d.createElement("tr");
+ totalrows++;
+ for (i = 0; i < field_counter_js; i++) {
+ td = d.createElement("td");
+ if(rowtype[i] == 'textbox') {
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'></input> ";
+ } else if(rowtype[i] == 'select') {
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'>$options</select> ";
+ } else {
+ td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input type='checkbox' name='" + rowname[i] + totalrows + "'></input> ";
+ }
+ tr.appendChild(td);
+ }
+ td = d.createElement("td");
+ td.rowSpan = "1";
+
+ td.innerHTML = '<input type="image" src="/themes/' + theme + '/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete">';
+ tr.appendChild(td);
+ tbody.appendChild(tr);
+ });
+})();
+
+function removeRow(el) {
+ var cel;
+ while (el && el.nodeName.toLowerCase() != "tr")
+ el = el.parentNode;
+
+ if (el && el.parentNode) {
+ cel = el.getElementsByTagName("td").item(0);
+ el.parentNode.removeChild(el);
+ }
+}
+
+function find_unique_field_name(field_name) {
+ // loop through field_name and strip off -NUMBER
+ var last_found_dash = 0;
+ for (var i = 0; i < field_name.length; i++) {
+ // is this a dash, if so, update
+ // last_found_dash
+ if (field_name.substr(i,1) == "-" )
+ last_found_dash = i;
+ }
+ if (last_found_dash < 1)
+ return field_name;
+ return(field_name.substr(0,last_found_dash));
+}
+</script>
+
+EOF;
+
+}
+
+?> \ No newline at end of file