2024-06-20 22:16:50 +08:00
{ config , . . . }:
2023-11-18 16:59:16 +08:00
{
2024-06-20 22:16:50 +08:00
# Crowdsec Local API key for the bouncer.
age . secrets . traefik-bouncer-key = {
rekeyFile = ../crowdsec/traefik-bouncer-key.age ;
owner = " t r a e f i k " ;
group = " t r a e f i k " ;
} ;
2023-11-18 16:59:16 +08:00
# Attached to the routers, pieces of middleware are a means of tweaking the requests before they are sent to your service
services . traefik . dynamicConfigOptions . http . middlewares = {
2023-11-20 06:41:07 +08:00
# Restrict access to admin devices only
admin . ipwhitelist . sourcerange = [
" 1 2 7 . 0 . 0 . 1 / 3 2 " # localhost
" 1 9 2 . 1 6 8 . 1 . 1 0 1 " # fuchsia
" 1 0 . 1 0 0 . 0 . 2 " # Pixel 6 Pro
] ;
2024-06-20 22:16:50 +08:00
2023-11-18 16:59:16 +08:00
# Restrict access to internal networks
internal . ipwhitelist . sourcerange = [
" 1 2 7 . 0 . 0 . 1 / 3 2 " # localhost
" 1 9 2 . 1 6 8 . 1 . 1 / 2 4 " # lan
2023-11-20 06:41:07 +08:00
" 1 0 . 1 0 0 . 0 . 0 / 2 4 " # wireguard clients
2023-11-18 16:59:16 +08:00
] ;
2024-06-20 22:16:50 +08:00
2023-11-18 16:59:16 +08:00
# Restrict access based on geo-location
geoblock . plugin . geoblock = {
2024-03-03 09:58:47 +08:00
silentStartUp = " f a l s e " ;
2023-11-18 16:59:16 +08:00
allowLocalRequests = " t r u e " ;
# If set to true will show a log message
logLocalRequests = " f a l s e " ;
logAllowedRequests = " f a l s e " ;
logApiRequests = " f a l s e " ;
# Application programming interface
api = " h t t p s : / / g e t . g e o j s . i o / v 1 / i p / c o u n t r y / { i p } " ;
2023-11-20 12:06:37 +08:00
apiTimeoutMs = " 7 5 0 " ;
2023-11-18 16:59:16 +08:00
# Max size of least recently used cache
cacheSize = " 2 5 " ;
2024-04-01 10:03:27 +08:00
# List of countries to block access
2023-11-18 16:59:16 +08:00
countries = [
2024-04-01 10:03:27 +08:00
" R U " # Russian Federation (the)
2023-11-18 16:59:16 +08:00
] ;
# Inverts filter logic
2024-04-01 10:03:27 +08:00
blackListMode = " t r u e " ;
2023-11-18 16:59:16 +08:00
# Unknown Countries (IPs with no country association)
allowUnknownCountries = " f a l s e " ;
unknownCountryApiResponse = " n i l " ;
# Adds the X-IPCountry header to the HTTP request header.
addCountryHeader = " f a l s e " ;
# Even if an IP stays in the cache for a period of a month, it must be fetch again after a month.
forceMonthlyUpdate = " t r u e " ;
} ;
2024-06-20 22:16:50 +08:00
# Disable Crowdsec IP checking but apply Crowdsec Appsec checking. This mode is intended to be used when Crowdsec IP checking is applied at the Firewall Level.
crowdsec . plugin . bouncer = {
enabled = " t r u e " ;
crowdsecMode = " a p p s e c " ;
crowdsecLapiKeyFile = config . age . secrets . traefik-bouncer-key . path ;
crowdsecLapiScheme = " h t t p " ;
crowdsecLapiHost = " 1 2 7 . 0 . 0 . 1 : 8 0 8 0 " ;
crowdsecAppsecEnabled = " t r u e " ;
crowdsecAppsecHost = " 1 2 7 . 0 . 0 . 1 : 7 4 2 2 " ;
} ;
2023-11-18 16:59:16 +08:00
} ;
}