From 29edd66368ef58cf8880e53f38607072e2df3c3c Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Thu, 14 Mar 2019 07:33:06 +0100 Subject: [PATCH] www/nginx: add basic VTS support --- www/nginx/Makefile | 2 +- www/nginx/pkg-descr | 6 ++++++ .../nginx/opnsense_http_vhost_plugins/vts.conf | 9 +++++++++ .../OPNsense/Nginx/Api/ServiceController.php | 17 +++++++++++++++++ www/nginx/src/opnsense/scripts/nginx/vts.php | 7 +++++++ .../service/conf/actions.d/actions_nginx.conf | 6 ++++++ 6 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 www/nginx/src/etc/nginx/opnsense_http_vhost_plugins/vts.conf create mode 100755 www/nginx/src/opnsense/scripts/nginx/vts.php diff --git a/www/nginx/Makefile b/www/nginx/Makefile index 7a27293a0..1491f1361 100644 --- a/www/nginx/Makefile +++ b/www/nginx/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= nginx -PLUGIN_VERSION= 1.10 +PLUGIN_VERSION= 1.11 PLUGIN_COMMENT= Nginx HTTP server and reverse proxy PLUGIN_DEPENDS= nginx PLUGIN_MAINTAINER= franz.fabian.94@gmail.com diff --git a/www/nginx/pkg-descr b/www/nginx/pkg-descr index 9634f9658..b71c7593e 100644 --- a/www/nginx/pkg-descr +++ b/www/nginx/pkg-descr @@ -8,6 +8,12 @@ reuse, SSL offload and HTTP media streaming. Plugin Changelog ================ +1.11 + +* add VTS(1) module for traffic status reports + +(1) https://github.com/vozlt/nginx-module-vts + 1.10 * fix content security settings (missing checkbox, correct templating) diff --git a/www/nginx/src/etc/nginx/opnsense_http_vhost_plugins/vts.conf b/www/nginx/src/etc/nginx/opnsense_http_vhost_plugins/vts.conf new file mode 100644 index 000000000..31ecda7e0 --- /dev/null +++ b/www/nginx/src/etc/nginx/opnsense_http_vhost_plugins/vts.conf @@ -0,0 +1,9 @@ +vhost_traffic_status_zone shared:vhost_traffic_status:20m; +server { + listen unix:/var/run/nginx_status.sock; + location /vts { + vhost_traffic_status_display; + vhost_traffic_status_display_format json; + } +} + diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/ServiceController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/ServiceController.php index bffa8afbb..c72fa511c 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/ServiceController.php +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/ServiceController.php @@ -100,4 +100,21 @@ class ServiceController extends ApiMutableServiceControllerBase return array('status' => $status); } + + /** + * retrieve extended status of service + * @return array response message + * @throws \Exception when configd action fails + */ + public function vtsAction() + { + $backend = new Backend(); + $vts = json_decode($backend->configdRun('nginx vts'), true); + if ($vts != null) { + return $vts; + } + + $this->response->setStatusCode(404, "Not Found"); + return array(); + } } diff --git a/www/nginx/src/opnsense/scripts/nginx/vts.php b/www/nginx/src/opnsense/scripts/nginx/vts.php new file mode 100755 index 000000000..9246f89ef --- /dev/null +++ b/www/nginx/src/opnsense/scripts/nginx/vts.php @@ -0,0 +1,7 @@ +#!/usr/local/bin/php +