forked from jan-leila/nix-config
		
	moved fail2ban configs into service configs
This commit is contained in:
		
							parent
							
								
									76d68cf146
								
							
						
					
					
						commit
						c7938c3fe7
					
				
					 4 changed files with 73 additions and 44 deletions
				
			
		|  | @ -1,6 +1,7 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   pkgs, | ||||
|   ... | ||||
| }: let | ||||
|   forgejoPort = 8081; | ||||
|  | @ -67,6 +68,31 @@ in { | |||
|         config.services.forgejo.settings.server.SSH_LISTEN_PORT | ||||
|       ]; | ||||
|     } | ||||
|     (lib.mkIf config.services.fail2ban.enable { | ||||
|       environment.etc = { | ||||
|         "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>" | ||||
|           '') | ||||
|         ); | ||||
|       }; | ||||
| 
 | ||||
|       services.fail2ban = { | ||||
|         jails = { | ||||
|           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.settings.log.ROOT_PATH}/*.log"; | ||||
|             backend = "auto"; | ||||
|             findtime = 600; | ||||
|             bantime = 600; | ||||
|             maxretry = 5; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
|     }) | ||||
|     (lib.mkIf config.host.impermanence.enable { | ||||
|       assertions = [ | ||||
|         { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue