From abb981ad6537e9c6f8c887130a6ffef0fd0cf469 Mon Sep 17 00:00:00 2001 From: Fabian Franz BSc Date: Sun, 6 Jan 2019 19:26:35 +0100 Subject: [PATCH] www/nginx: bugfix log not found (#1113) * www/nginx: bugfix log not found * www/nginx: release note --- www/nginx/pkg-descr | 1 + .../src/opnsense/scripts/nginx/read_log.php | 34 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/www/nginx/pkg-descr b/www/nginx/pkg-descr index 6533d34b4..b163290cc 100644 --- a/www/nginx/pkg-descr +++ b/www/nginx/pkg-descr @@ -11,6 +11,7 @@ Plugin Changelog 1.6 * fix bug due to permission downgrade (basic auth) +* fix bug when multiple hostnames are used, that the logs are not displayed in the log viewer * add paging support to log viewer, so it does not crash on really big log files * add basic TLS fingerprint check to make man in the middle attacks visible (may not fully work on LibreSSL crypto flavour as curves seem to return an empty string) * add dropdown to select authentication backend in HTTP server for advanced authentication diff --git a/www/nginx/src/opnsense/scripts/nginx/read_log.php b/www/nginx/src/opnsense/scripts/nginx/read_log.php index 20fe435e8..35cae23f5 100755 --- a/www/nginx/src/opnsense/scripts/nginx/read_log.php +++ b/www/nginx/src/opnsense/scripts/nginx/read_log.php @@ -64,25 +64,23 @@ switch ($mode) { die('{"error": "The server entry has no server name"}'); } $lines = []; - foreach (explode(',', $server_names) as $server_name) { - $log_file_name = $log_prefix . basename($server_name) . '.' . $mode . $log_suffix; - // this entry has no log file, ignore it - if (!file_exists($log_file_name)) { - continue; - } - $logparser = null; - - if ($mode == 'error') { - $logparser = new ErrorLogParser($log_file_name); - } elseif ($mode == 'access') { - $logparser = new AccessLogParser($log_file_name); - } - // we cannot parse the file - something went wrong - if ($logparser == null) { - continue; - } - $lines = array_merge($lines, $logparser->get_result()); + $log_file_name = $log_prefix . basename($server_names) . '.' . $mode . $log_suffix; + // this entry has no log file, ignore it + if (!file_exists($log_file_name)) { + continue; } + $logparser = null; + + if ($mode == 'error') { + $logparser = new ErrorLogParser($log_file_name); + } elseif ($mode == 'access') { + $logparser = new AccessLogParser($log_file_name); + } + // we cannot parse the file - something went wrong + if ($logparser == null) { + continue; + } + $lines = array_merge($lines, $logparser->get_result()); if (empty($lines)) { $lines['error'] = 'no lines found'; }