mirror of
				https://github.com/linuxserver/docker-swag.git
				synced 2025-11-01 05:27:42 +09:00 
			
		
		
		
	Added a fail2ban jail for nginx unauthorized
This commit is contained in:
		| @@ -330,6 +330,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64 | |||||||
|  |  | ||||||
| ## Versions | ## Versions | ||||||
|  |  | ||||||
|  | * **09.01.22:** - Added a fail2ban jail for nginx unauthorized | ||||||
| * **21.12.21:** - Fixed issue with iptables not working as expected | * **21.12.21:** - Fixed issue with iptables not working as expected | ||||||
| * **30.11.21:** - Move maxmind to a [new mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind) | * **30.11.21:** - Move maxmind to a [new mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind) | ||||||
| * **22.11.21:** - Added support for Infomaniak DNS for certificate generation. | * **22.11.21:** - Added support for Infomaniak DNS for certificate generation. | ||||||
|   | |||||||
| @@ -154,6 +154,7 @@ app_setup_nginx_reverse_proxy_block: "" | |||||||
|  |  | ||||||
| # changelog | # changelog | ||||||
| changelogs: | changelogs: | ||||||
|  |   - { date: "09.01.22:", desc: "Added a fail2ban jail for nginx unauthorized" } | ||||||
|   - { date: "21.12.21:", desc: "Fixed issue with iptables not working as expected" } |   - { date: "21.12.21:", desc: "Fixed issue with iptables not working as expected" } | ||||||
|   - { date: "30.11.21:", desc: "Move maxmind to a [new mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind)" } |   - { date: "30.11.21:", desc: "Move maxmind to a [new mod](https://github.com/linuxserver/docker-mods/tree/swag-maxmind)" } | ||||||
|   - { date: "22.11.21:", desc: "Added support for Infomaniak DNS for certificate generation." } |   - { date: "22.11.21:", desc: "Added support for Infomaniak DNS for certificate generation." } | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								root/defaults/fail2ban/filter.d/nginx-unauthorized.conf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								root/defaults/fail2ban/filter.d/nginx-unauthorized.conf
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  | # A fail2ban filter for unauthorized log messages | ||||||
|  |  | ||||||
|  | [Definition] | ||||||
|  |  | ||||||
|  | failregex = ^<HOST>.*"(GET|POST|HEAD).*" 401 .*$ | ||||||
|  |  | ||||||
|  | ignoreregex =  | ||||||
| @@ -1,10 +1,14 @@ | |||||||
| ## Version 2020/05/10 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/jail.local | ## Version 2022/01/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/jail.local | ||||||
| # This is the custom version of the jail.conf for fail2ban | # This is the custom version of the jail.conf for fail2ban | ||||||
| # Feel free to modify this and add additional filters | # Feel free to modify this and add additional filters | ||||||
| # Then you can drop the new filter conf files into the fail2ban-filters | # Then you can drop the new filter conf files into the fail2ban-filters | ||||||
| # folder and restart the container | # folder and restart the container | ||||||
|  |  | ||||||
| [DEFAULT] | [DEFAULT] | ||||||
|  | # Prevents banning LAN subnets | ||||||
|  | ignoreip = 10.0.0.0/8 | ||||||
|  |            192.168.0.0/16 | ||||||
|  |            172.16.0.0/12 | ||||||
|  |  | ||||||
| # Changes the default ban action from "iptables-multiport", which causes issues on some platforms, to "iptables-allports". | # Changes the default ban action from "iptables-multiport", which causes issues on some platforms, to "iptables-allports". | ||||||
| banaction = iptables-allports | banaction = iptables-allports | ||||||
| @@ -21,37 +25,35 @@ maxretry = 5 | |||||||
|  |  | ||||||
|  |  | ||||||
| [ssh] | [ssh] | ||||||
|  |  | ||||||
| enabled = false | enabled = false | ||||||
|  |  | ||||||
|  |  | ||||||
| [nginx-http-auth] | [nginx-http-auth] | ||||||
|  |  | ||||||
| enabled  = true | enabled  = true | ||||||
| filter   = nginx-http-auth | filter   = nginx-http-auth | ||||||
| port     = http,https | port     = http,https | ||||||
| logpath  = /config/log/nginx/error.log | logpath  = /config/log/nginx/error.log | ||||||
|  |  | ||||||
|  |  | ||||||
| [nginx-badbots] | [nginx-badbots] | ||||||
|  |  | ||||||
| enabled  = true | enabled  = true | ||||||
| port     = http,https | port     = http,https | ||||||
| filter   = nginx-badbots | filter   = nginx-badbots | ||||||
| logpath  = /config/log/nginx/access.log | logpath  = /config/log/nginx/access.log | ||||||
| maxretry = 2 | maxretry = 2 | ||||||
|  |  | ||||||
|  |  | ||||||
| [nginx-botsearch] | [nginx-botsearch] | ||||||
|  |  | ||||||
| enabled  = true | enabled  = true | ||||||
| port     = http,https | port     = http,https | ||||||
| filter   = nginx-botsearch | filter   = nginx-botsearch | ||||||
| logpath  = /config/log/nginx/access.log | logpath  = /config/log/nginx/access.log | ||||||
|  |  | ||||||
| [nginx-deny] | [nginx-deny] | ||||||
|  |  | ||||||
| enabled  = true | enabled  = true | ||||||
| port     = http,https | port     = http,https | ||||||
| filter   = nginx-deny | filter   = nginx-deny | ||||||
| logpath  = /config/log/nginx/error.log | logpath  = /config/log/nginx/error.log | ||||||
|  |  | ||||||
|  | [nginx-unauthorized] | ||||||
|  | enabled  = true | ||||||
|  | port     = http,https | ||||||
|  | filter   = nginx-unauthorized | ||||||
|  | logpath  = /config/log/nginx/unauthorized.log | ||||||
|   | |||||||
| @@ -1,4 +1,4 @@ | |||||||
| ## Version 2021/04/27 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx.conf | ## Version 2022/01/09 - Changelog: https://github.com/linuxserver/docker-swag/commits/master/root/defaults/nginx.conf | ||||||
|  |  | ||||||
| user abc; | user abc; | ||||||
|  |  | ||||||
| @@ -55,6 +55,13 @@ http { | |||||||
|         '' close; |         '' close; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     # Saves unauthorized log messages to a separate log file | ||||||
|  |     map $status $unauthorized { | ||||||
|  |         default 0; | ||||||
|  |         ~^401  1; | ||||||
|  |     } | ||||||
|  |     access_log /config/log/nginx/unauthorized.log combined if=$unauthorized; | ||||||
|  |      | ||||||
|     # Sets the path, format, and configuration for a buffered log write. |     # Sets the path, format, and configuration for a buffered log write. | ||||||
|     access_log /config/log/nginx/access.log; |     access_log /config/log/nginx/access.log; | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user