diff --git a/net/haproxy/Makefile b/net/haproxy/Makefile index 2b341765a..6fdde0d7d 100644 --- a/net/haproxy/Makefile +++ b/net/haproxy/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= haproxy -PLUGIN_VERSION= 0.2 +PLUGIN_VERSION= 0.3 PLUGIN_PRIVATE= yes PLUGIN_COMMENT= Reliable, high performance TCP/HTTP load balancer PLUGIN_DEPENDS= haproxy diff --git a/net/haproxy/src/etc/inc/plugins.inc.d/haproxy.inc b/net/haproxy/src/etc/inc/plugins.inc.d/haproxy.inc new file mode 100644 index 000000000..89ed9eb15 --- /dev/null +++ b/net/haproxy/src/etc/inc/plugins.inc.d/haproxy.inc @@ -0,0 +1,64 @@ + array('haproxy'), "remote" => "haproxy"); + return $syslogconf; +} + +/** + * register legacy service + * @return array + */ +function haproxy_services() +{ + global $config; + $services = array(); + + if (isset($config['OPNsense']['HAProxy']['general']['enabled']) && $config['OPNsense']['HAProxy']['general']['enabled'] == 1) { + $services[] = array( + 'description' => gettext('HAProxy load balancer'), + 'configd' => array( + 'restart' => array('haproxy restart'), + 'start' => array('haproxy start'), + 'stop' => array('haproxy stop'), + ), + 'name' => 'haproxy', + ); + } + + return $services; +} diff --git a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml index 94c57028c..196da4983 100644 --- a/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml +++ b/net/haproxy/src/opnsense/mvc/app/controllers/OPNsense/HAProxy/forms/main.xml @@ -17,6 +17,12 @@ info + + haproxy.general.tuning.chroot + + checkbox +
NOTE: Enabling chroot will deactivate logging to localhost, because the local syslogd is running in secure mode and does not accept network connections (and it's log socket is not accessible from the chroot directory). You'll need to log to a remote host when enabling the chroot feature.
]]>
+
haproxy.general.tuning.nbproc diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml index 74ae5cbbe..9f21a2c23 100644 --- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml +++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/HAProxy.xml @@ -10,6 +10,10 @@ Y + + 0 + Y + 1 500000 @@ -132,7 +136,7 @@ daemon ftp kern - local0 + local0 [default] local1 local2 local3 @@ -151,13 +155,14 @@ N + info alert crit debug emerg err - info + info [default] notice warning diff --git a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/Menu/Menu.xml b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/Menu/Menu.xml index 5e04f9d37..d91b7c8ed 100644 --- a/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/Menu/Menu.xml +++ b/net/haproxy/src/opnsense/mvc/app/models/OPNsense/HAProxy/Menu/Menu.xml @@ -22,7 +22,7 @@ - + diff --git a/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/statistics.volt b/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/statistics.volt index 76bbb626f..aa4473c04 100644 --- a/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/statistics.volt +++ b/net/haproxy/src/opnsense/mvc/app/views/OPNsense/HAProxy/statistics.volt @@ -49,6 +49,8 @@ POSSIBILITY OF SUCH DAMAGE. $('#infolist').append(''+key+'' + ""+value+""); }); + } else { + $("#infolist").html("
Error: Unable to fetch statistics. Is HAProxy running?"); } $('#processing-dialog').modal('hide'); } diff --git a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/setup.sh b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/setup.sh index b8c57f0f0..12cde91c0 100755 --- a/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/setup.sh +++ b/net/haproxy/src/opnsense/scripts/OPNsense/HAProxy/setup.sh @@ -1,6 +1,6 @@ #!/bin/sh -HAPROXY_DIRS="/var/log/haproxy /var/run/haproxy /var/etc/haproxy/ssl /var/etc/haproxy/lua /var/etc/haproxy/errorfiles" +HAPROXY_DIRS="/var/run/haproxy /var/etc/haproxy/ssl /var/etc/haproxy/lua /var/etc/haproxy/errorfiles" for directory in ${HAPROXY_DIRS}; do mkdir -p ${directory} diff --git a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf index ebb6657ec..51b6f4a12 100644 --- a/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf +++ b/net/haproxy/src/opnsense/service/templates/OPNsense/HAProxy/haproxy.conf @@ -443,7 +443,11 @@ global uid 80 gid 80 +{% if OPNsense.HAProxy.general.tuning.chroot == "1" %} + # NOTE: chroot prevents (most) local logging, you need to enable remote + # logging when using it (because syslogd is running in secure mode). chroot /var/run/haproxy +{% endif %} daemon stats socket /var/run/haproxy.socket level admin nbproc {{OPNsense.HAProxy.general.tuning.nbproc}} @@ -465,12 +469,18 @@ global {% if OPNsense.HAProxy.general.tuning.luaMaxMem|default("") != "" %} tune.lua.maxmem {{OPNsense.HAProxy.general.tuning.luaMaxMem}} {% endif %} -{# # logging configuration #} -{% set logging = [] %} -{% do logging.append(OPNsense.HAProxy.general.logging.host) %} -{% do logging.append('len ' ~ OPNsense.HAProxy.general.logging.length) if OPNsense.HAProxy.general.logging.length|default("") != "" %} -{% do logging.append(OPNsense.HAProxy.general.logging.facility) %} -{% do logging.append(OPNsense.HAProxy.general.logging.level) if OPNsense.HAProxy.general.logging.level|default("") != "" %} +{# # logging configuration #} +{% set logging = [] %} +{% if OPNsense.HAProxy.general.logging.host != '127.0.0.1' %} +{% do logging.append(OPNsense.HAProxy.general.logging.host) %} +{% else %} +{# # NOTE: syslogd is running is secure mode and thus does not accept network #} +{# # connections. That's why we need to use the log socket instead. #} +{% do logging.append('/var/run/log') %} +{% endif %} +{% do logging.append('len ' ~ OPNsense.HAProxy.general.logging.length) if OPNsense.HAProxy.general.logging.length|default("") != "" %} +{% do logging.append(OPNsense.HAProxy.general.logging.facility) %} +{% do logging.append(OPNsense.HAProxy.general.logging.level) if OPNsense.HAProxy.general.logging.level|default("") != "" %} log {{logging|join(' ')}} {% if OPNsense.HAProxy.luas.lua is defined %} # lua scripts diff --git a/net/haproxy/src/www/diag_logs_haproxy.php b/net/haproxy/src/www/diag_logs_haproxy.php new file mode 100644 index 000000000..dfd8a441c --- /dev/null +++ b/net/haproxy/src/www/diag_logs_haproxy.php @@ -0,0 +1,6 @@ +