Prechádzať zdrojové kódy

Update fail2ban configs to support multiple hosts, new log loc

George Baugh 1 rok pred
rodič
commit
892ae90af1
4 zmenil súbory, kde vykonal 21 pridanie a 3 odobranie
  1. 1 0
      .gitignore
  2. 6 2
      Installer.mk
  3. 13 0
      bin/tcms-hostname
  4. 1 1
      fail2ban/tcms-jail.tmpl

+ 1 - 0
.gitignore

@@ -27,6 +27,7 @@ node_modules/
 www/statics/
 totp/
 nginx/tcms.conf
+fail2ban/tcms-jail.conf
 logs/
 *-shm
 *-wal

+ 6 - 2
Installer.mk

@@ -72,8 +72,12 @@ reset-remove:
 
 .PHONY: fail2ban
 fail2ban:
-	sudo ln -sr fail2ban/tcms-jail.conf   /etc/fail2ban/jail.d/tcms.conf
-	sudo ln -sr fail2ban/tcms-filter.conf /etc/fail2ban/filter.d/tcms.conf
+	cp fail2ban/tcms-jail.tmpl fail2ban/tcms-jail.conf
+	sed -i 's#__LOGDIR__#$(shell pwd)#g' fail2ban/tcms-jail.conf
+	sudo rm /etc/fail2ban/jail.d/$(shell bin/tcms-hostname).conf; /bin/true
+	sudo rm /etc/fail2ban/filter.d/$(shell bin/tcms-hostname).conf; /bin/true
+	sudo ln -sr fail2ban/tcms-jail.conf   /etc/fail2ban/jail.d/$(shell bin/tcms-hostname).conf
+	sudo ln -sr fail2ban/tcms-filter.conf /etc/fail2ban/filter.d/$(shell bin/tcms-hostname).conf
 	sudo systemctl reload fail2ban
 
 .PHONY: nginx

+ 13 - 0
bin/tcms-hostname

@@ -0,0 +1,13 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+use FindBin::libs;
+
+use Trog::Config();
+
+my $domain = Trog::Config->get()->param('general.hostname');
+die "Hostname not set in tCMS configuration.  Please set this first." unless $domain;
+
+print "$domain\n";

+ 1 - 1
fail2ban/tcms-jail.conf → fail2ban/tcms-jail.tmpl

@@ -2,7 +2,7 @@
 enabled = true
 port = http,https
 filter = tcms
-logpath = /var/log/www/tcms.log
+logpath = __LOGDIR__/tcms.log
 maxretry = 5
 findtime = 60
 bantime  = 600