forked from jan-leila/nix-config
		
	removed next cloud
This commit is contained in:
		
							parent
							
								
									c4c84503f5
								
							
						
					
					
						commit
						769da44f84
					
				
					 4 changed files with 41 additions and 93 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| { | ||||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   ... | ||||
| }: let | ||||
|  | @ -12,6 +13,41 @@ in { | |||
| 
 | ||||
|   config = lib.mkIf config.host.fail2ban.enable (lib.mkMerge [ | ||||
|     { | ||||
|       environment.etc = { | ||||
|         "fail2ban/filter.d/nginx.local".text = lib.mkIf config.services.nginx.enable ( | ||||
|           pkgs.lib.mkDefault (pkgs.lib.mkAfter '' | ||||
|             [Definition] | ||||
|             failregex = "limiting requests, excess:.* by zone.*client: <HOST>" | ||||
|           '') | ||||
|         ); | ||||
|         "fail2ban/filter.d/jellyfin.local".text = lib.mkIf config.services.jellyfin.enable ( | ||||
|           pkgs.lib.mkDefault (pkgs.lib.mkAfter '' | ||||
|             [Definition] | ||||
|             failregex = "^.*Authentication request for .* has been denied \\\(IP: \"<ADDR>\"\\\)\\\." | ||||
|           '') | ||||
|         ); | ||||
|         "fail2ban/filter.d/forgejo.local".text = lib.mkIf config.services.forgejo.enable ( | ||||
|           pkgs.lib.mkDefault (pkgs.lib.mkAfter '' | ||||
|             [Definition] | ||||
|             failregex = ".*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>" | ||||
|           '') | ||||
|         ); | ||||
|         "fail2ban/filter.d/hass.local".text = lib.mkIf config.services.home-assistant.enable ( | ||||
|           pkgs.lib.mkDefault (pkgs.lib.mkAfter '' | ||||
|             [INCLUDES] | ||||
|             before = common.conf | ||||
| 
 | ||||
|             [Definition] | ||||
|             failregex = ^%(__prefix_line)s.*Login attempt or request with invalid authentication from <HOST>.*$ | ||||
| 
 | ||||
|             ignoreregex = | ||||
| 
 | ||||
|             [Init] | ||||
|             datepattern = ^%%Y-%%m-%%d %%H:%%M:%%S | ||||
|           '') | ||||
|         ); | ||||
|       }; | ||||
| 
 | ||||
|       services.fail2ban = { | ||||
|         enable = true; | ||||
|         maxretry = 5; | ||||
|  | @ -34,54 +70,40 @@ in { | |||
|         }; | ||||
|         jails = { | ||||
|           nginx-iptables.settings = lib.mkIf config.services.nginx.enable { | ||||
|             enabled = true; | ||||
|             filter = "nginx"; | ||||
|             action = ''iptables-multiport[name=HTTP, port="http,https"]''; | ||||
|             backend = "auto"; | ||||
|             failregex = "limiting requests, excess:.* by zone.*client: <HOST>"; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|           }; | ||||
|           jellyfin-iptables.settings = lib.mkIf config.services.jellyfin.enable { | ||||
|             enabled = true; | ||||
|             filter = "jellyfin"; | ||||
|             action = ''iptables-multiport[name=HTTP, port="http,https"]''; | ||||
|             logpath = "${config.services.jellyfin.dataDir}/log/*.log"; | ||||
|             backend = "auto"; | ||||
|             failregex = "^.*Authentication request for .* has been denied \\\(IP: \"<ADDR>\"\\\)\\\."; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|           }; | ||||
|           nextcloud-iptables.settings = lib.mkIf config.services.nextcloud.enable { | ||||
|             filter = "nextcloud"; | ||||
|             action = ''iptables-multiport[name=HTTP, port="http,https"]''; | ||||
|             logpath = "${config.services.nextcloud.datadir}/*.log"; | ||||
|             backend = "auto"; | ||||
|             failregex = '' | ||||
|               ^{"reqId":".*","remoteAddr":".*","app":"core","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)","level":2,"time":".*"}$ | ||||
|                           ^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","user,:".*","app":"no app in context".*","method":".*","message":"Login failed: '.*' \(Remote IP: '<HOST>'\)".*}$ | ||||
|                           ^{"reqId":".*","level":2,"time":".*","remoteAddr":".*","user":".*","app":".*","method":".*","url":".*","message":"Login failed: .* \(Remote IP: <HOST>\).*}$ | ||||
|             ''; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|           }; | ||||
|           forgejo-iptables.settings = lib.mkIf config.services.forgejo.enable { | ||||
|             enabled = true; | ||||
|             filter = "forgejo"; | ||||
|             action = ''iptables-multiport[name=HTTP, port="http,https"]''; | ||||
|             logpath = "${config.services.forgejo.stateDir}/log/*.log"; | ||||
|             backend = "auto"; | ||||
|             failregex = ".*(Failed authentication attempt|invalid credentials|Attempted access of unknown user).* from <HOST>"; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|           }; | ||||
|           home-assistant-iptables.settings = lib.mkIf config.services.home-assistant.enable { | ||||
|             filter = "home-assistant"; | ||||
|             enabled = true; | ||||
|             filter = "hass"; | ||||
|             action = ''iptables-multiport[name=HTTP, port="http,https"]''; | ||||
|             logpath = "${config.services.home-assistant.configDir}/*.log"; | ||||
|             backend = "auto"; | ||||
|             failregex = "^%(__prefix_line)s.*Login attempt or request with invalid authentication from <HOST>.*$"; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue