Merge pull request #1255 from opnsense/ngx_vts_api

www/nginx: add basic VTS support
This commit is contained in:
Fabian Franz BSc
2019-03-27 17:52:24 +01:00
committed by GitHub
6 changed files with 46 additions and 1 deletions
+1 -1
View File
@@ -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
+6
View File
@@ -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)
@@ -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;
}
}
@@ -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();
}
}
+7
View File
@@ -0,0 +1,7 @@
#!/usr/local/bin/php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, '/var/run/nginx_status.sock');
curl_setopt($ch, CURLOPT_URL, "http://localhost/vts");
curl_exec($ch);
@@ -55,3 +55,9 @@ description:Automatically ban attacking hosts (nginx plugin)
command:/usr/local/opnsense/scripts/nginx/naxsi_rule_download.php
parameters:
type:script
[vts]
command:/usr/local/opnsense/scripts/nginx/vts.php
parameters:
type:script_output