dotfiles.nix/nixos/viridian/services/traefik/middlewares.nix

66 lines
2.2 KiB
Nix
Raw Normal View History

2024-11-23 20:18:08 +08:00
{...}: {
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 = {
# Restrict access to internal networks
internal.ipwhitelist.sourcerange = [
2024-08-08 09:02:42 +08:00
"127.0.0.1/32" # localhost
2024-09-07 15:49:39 +08:00
"192.168.50.1/24" # lan
2023-11-18 16:59:16 +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 = "false";
2023-11-18 16:59:16 +08:00
allowLocalRequests = "true";
# If set to true will show a log message
logLocalRequests = "false";
logAllowedRequests = "false";
logApiRequests = "false";
# Application programming interface
api = "https://get.geojs.io/v1/ip/country/{ip}";
2023-11-20 12:06:37 +08:00
apiTimeoutMs = "750";
2023-11-18 16:59:16 +08:00
# Max size of least recently used cache
cacheSize = "25";
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
"RU" # Russian Federation (the)
2023-11-18 16:59:16 +08:00
];
# Inverts filter logic
2024-04-01 10:03:27 +08:00
blackListMode = "true";
2023-11-18 16:59:16 +08:00
# Unknown Countries (IPs with no country association)
allowUnknownCountries = "false";
unknownCountryApiResponse = "nil";
# Adds the X-IPCountry header to the HTTP request header.
addCountryHeader = "false";
# Even if an IP stays in the cache for a period of a month, it must be fetch again after a month.
forceMonthlyUpdate = "true";
};
2024-11-23 20:18:08 +08:00
# Intrusion Prevention System
crowdsec.plugin.bouncer = {
enabled = "true";
2024-11-23 20:18:08 +08:00
defaultDecisionSeconds = "60";
crowdsecMode = "live";
crowdsecAppsecEnabled = "true";
2024-11-23 20:18:08 +08:00
crowdsecAppsecHost = "localhost:7422";
crowdsecAppsecFailureBlock = "true";
crowdsecAppsecUnreachableBlock = "true";
crowdsecLapiKey = "18c725d5-3a22-4331-a8e8-abfd3018a7c0";
crowdsecLapiHost = "localhost:8080";
crowdsecLapiScheme = "http";
crowdsecLapiTLSInsecureVerify = "false";
forwardedHeadersTrustedIPs = [
# private class ranges
"10.0.0.0/8"
"172.16.0.0/12"
"192.168.0.0/16"
];
clientTrustedIPs = [
# private class ranges
"10.0.0.0/8"
"172.16.0.0/12"
"192.168.0.0/16"
];
};
2023-11-18 16:59:16 +08:00
};
}