0) { header("Location: haproxy_listeners.php"); echo "touching: $d_haproxyconfdirty_path"; touch($d_haproxyconfdirty_path); write_config($changedesc); exit; } } function template_errorfile() { global $config, $d_haproxyconfdirty_path, $savemsg; $a_files = &$config['installedpackages']['haproxy']['files']['item']; if (!is_array($a_files)) $a_files = array(); $a_files_cache = haproxy_get_fileslist(); if (!isset($a_files_cache["ExampleErrorfile"])) { $errorfile = << Sorry the webserver you are trying to contact is currently not available.

Sorry the webserver you are trying to contact is currently not available.

The error returned is [{errorcode} {errormsg}] please try again later. EOD; $newfile = array(); $newfile['name'] = "ExampleErrorfile"; $newfile['content'] = base64_encode($errorfile); $a_files[] = $newfile; $changecount++; $changedesc = "Errorfile added from template"; } else { $savemsg = "File 'ExampleErrorfile' is already configured on the Files tab."; } $changedesc = "haproxy, add template errorfile"; if ($changecount > 0) { header("Location: haproxy_files.php"); echo "touching: $d_haproxyconfdirty_path"; touch($d_haproxyconfdirty_path); write_config($changedesc); exit; } } function haproxy_template_multipledomains() { global $config, $d_haproxyconfdirty_path; $a_backends = &$config['installedpackages']['haproxy']['ha_pools']['item']; $a_frontends = &$config['installedpackages']['haproxy']['ha_backends']['item']; $backend = array(); $backend["name"] = "example_backend1"; $backend["stats_enabled"] = "yes"; $backend["stats_uri"] = "/"; $backend["stats_refresh"] = "10"; $backend["stats_scope"] = "."; $backend["stats_node"] = "NODE1"; $a_backends[] = $backend; $backend = array(); $backend["name"] = "example_backend2"; $backend["stats_enabled"] = "yes"; $backend["stats_uri"] = "/"; $backend["stats_refresh"] = "10"; $backend["stats_scope"] = "."; $backend["stats_node"] = "NODE2"; $a_backends[] = $backend; $backend = array(); $backend["name"] = "example_backend3"; $backend["stats_enabled"] = "yes"; $backend["stats_uri"] = "/"; $backend["stats_refresh"] = "10"; $backend["stats_scope"] = "."; $backend["stats_node"] = "NODE3"; $a_backends[] = $backend; $frontend = array(); $frontend["name"] = "example_multipledomains"; $frontend["status"] = "active"; $frontend["type"] = "http"; $frontend["a_extaddr"]["item"]["stats_name"]["extaddr"] = "wan_ipv4"; $frontend["a_extaddr"]["item"]["stats_name"]["extaddr_port"] = "80"; $frontend["backend_serverpool"] = "example_backend1"; $acl = array(); $acl["name"] = "mail_acl"; $acl["expression"] = "host_matches"; $acl["value"] = "mail.domain.tld"; $frontend["ha_acls"]["item"][] = $acl; $action = array(); $action["action"] = "use_backend"; $action["use_backendbackend"] = "example_backend2"; $action["acl"] = "mail_acl"; $frontend["a_actionitems"]["item"][] = $action; $a_frontends[] = $frontend; $frontend = array(); $frontend["name"] = "example_multipledomains_forum"; $frontend["status"] = "active"; $frontend["secondary"] = "yes"; $frontend["primary_frontend"] = "example_multipledomains"; $acl = array(); $acl["name"] = "forum_acl"; $acl["expression"] = "host_matches"; $acl["value"] = "forum.domain.tld"; $frontend["ha_acls"]["item"][] = $acl; $action = array(); $action["action"] = "use_backend"; $action["use_backendbackend"] = "example_backend3"; $action["acl"] = "forum_acl"; $frontend["a_actionitems"]["item"][] = $action; $a_frontends[] = $frontend; $changedesc = "haproxy, add multi domain example"; header("Location: haproxy_listeners.php"); echo "touching: $d_haproxyconfdirty_path"; touch($d_haproxyconfdirty_path); write_config($changedesc); exit; } if (isset($_GET['add_stats_example'])) { $templateid = $_GET['add_stats_example']; switch ($templateid) { case "1": haproxy_add_stats_example(); break; case "2": template_errorfile(); break; case "3": haproxy_template_multipledomains(); break; } } if ($_POST) { if ($_POST['apply']) { $result = haproxy_check_and_run($savemsg, true); if ($result) unlink_if_exists($d_haproxyconfdirty_path); } } $pgtitle = "Services: HAProxy: Templates"; include("head.inc"); haproxy_css(); ?>
You must apply the changes in order for them to take effect.");?>
Templates
This page contains some templates that can be added into the haproxy configuration to possible ways to configure haproxy using this the webgui from this package.
 
Serving multiple domains from 1 frontend.
Create configuration As an basic example of how to serve multiple domains on 1 listening ip:port.
 
Stats SSL frontent+backend
Create configuration As an basic example you can use the link below to create a 'stats' frontend/backend page which offers with more options like setting user/password and 'admin mode' when you go to the backend settings.
TEMPLATE: Create stats example configuration using a frontend/backend combination with ssl

After applying the changes made by the template use this link to visit the stats page: :444">https://pfSense-LAN-ip:444/
 
Errorfile
Create configuration As an basic example of an errorfile with name 'ExampleErrorfile' will be added if it does not exist. This file can then be used in the 'Error files' in the backend settings.