Added support for more configurations

This commit is contained in:
quietsy
2022-03-19 14:51:51 +02:00
parent 0d6152cc49
commit a9c87c81df
4 changed files with 86 additions and 24 deletions
@@ -1,6 +1,54 @@
## Version 2022/01/14
# Make sure that your dns has a cname set for dashboard
server {
listen 81;
server_name _;
root /dashboard/www;
index index.php;
client_max_body_size 0;
# enable for ldap auth, fill in ldap details in ldap.conf
#include /config/nginx/ldap.conf;
# enable for Authelia
#include /config/nginx/authelia-server.conf;
location / {
# enable the next two lines for http auth
#auth_basic "Restricted";
#auth_basic_user_file /config/nginx/.htpasswd;
# enable the next two lines for ldap auth
#auth_request /auth;
#error_page 401 =200 /ldaplogin;
# enable for Authelia
#include /config/nginx/authelia-location.conf;
allow 10.0.0.0/8;
allow 172.16.0.0/12;
allow 192.168.0.0/16;
deny all;
try_files $uri $uri/ /index.php?$args =404;
}
location ~ \.php$ {
allow 10.0.0.0/8;
allow 172.16.0.0/12;
allow 192.168.0.0/16;
deny all;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
+26 -19
View File
@@ -1,25 +1,32 @@
import json
import os
import sqlite3
def _get_f2b_data(db_path):
if not os.path.isfile(db_path):
return []
con = sqlite3.connect(db_path)
cur = con.cursor()
results = cur.execute("""
SELECT jails.name,
COUNT(bans.ip) AS bans,
(SELECT DISTINCT bans.ip from bans where jails.name = bans.jail ORDER BY timeofban DESC) as last_ban,
(SELECT DISTINCT bans.data from bans where jails.name = bans.jail ORDER BY timeofban DESC) as data
FROM jails
LEFT JOIN bans ON jails.name=bans.jail
GROUP BY jails.name
""").fetchall()
con.close()
return [{
"name": name,
"bans": bans,
"last_ban": last_ban,
"data": json.dumps(json.loads(data), indent=4, sort_keys=True) if data else None
} for (name, bans, last_ban, data) in results]
con = sqlite3.connect("/config/fail2ban/fail2ban.sqlite3")
cur = con.cursor()
results = cur.execute("""
SELECT jails.name,
COUNT(bans.ip) AS bans,
(SELECT DISTINCT bans.ip from bans where jails.name = bans.jail ORDER BY timeofban DESC) as last_ban,
(SELECT DISTINCT bans.data from bans where jails.name = bans.jail ORDER BY timeofban DESC) as data
FROM jails
LEFT JOIN bans ON jails.name=bans.jail
GROUP BY jails.name
""").fetchall()
con.close()
formatted_results = [{
"name": name,
"bans": bans,
"last_ban": last_ban,
"data": json.dumps(json.loads(data), indent=4, sort_keys=True) if data else None
} for (name, bans, last_ban, data) in results]
swag_f2b = _get_f2b_data("/config/fail2ban/fail2ban.sqlite3")
host_f2b = _get_f2b_data("/dashboard/fail2ban/fail2ban.sqlite3")
output = json.dumps(formatted_results, sort_keys=True)
output = json.dumps(swag_f2b + host_f2b, sort_keys=True)
print(output)
+1 -2
View File
@@ -1,5 +1,4 @@
import collections
import contextlib
import concurrent.futures
import glob
import json
@@ -11,7 +10,7 @@ import urllib3
def find_apps():
apps = {}
file_paths = glob.glob("/config/nginx/**/*", recursive=True)
file_paths = glob.glob("/config/nginx/**/**", recursive=True)
auto_confs = glob.glob("/etc/nginx/http.d/*", recursive=True)
file_paths.extend(auto_confs)
for file_path in file_paths: