summaryrefslogtreecommitdiff
path: root/utils/templates
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2020-01-08 19:21:07 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2020-01-08 19:21:07 +0100
commit4139c63d23a1f4cc427eb428bcff0594c395c1c5 (patch)
tree6f5f0165244194f17acb85914d5ae80e3fdd798e /utils/templates
parent28dacee28819ea2d24fd8ff6547fd3a175677084 (diff)
utils/filtron.sh: add script to install filtron middleware
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'utils/templates')
-rw-r--r--utils/templates/etc/filtron/rules.json56
-rw-r--r--utils/templates/lib/systemd/system/filtron.service29
2 files changed, 85 insertions, 0 deletions
diff --git a/utils/templates/etc/filtron/rules.json b/utils/templates/etc/filtron/rules.json
new file mode 100644
index 000000000..4a232388e
--- /dev/null
+++ b/utils/templates/etc/filtron/rules.json
@@ -0,0 +1,56 @@
+[
+ {
+ "name": "api limit",
+ "interval": 60,
+ "limit": 1000,
+ "filters": ["Path=^/api"],
+ "aggregations": ["Path"],
+ "actions": [
+ {"name": "block"}
+ ],
+ "subrules": [
+ {
+ "name": "drop put",
+ "interval": 60,
+ "limit": 100,
+ "filters": ["Method=PUT"],
+ "aggregations": ["Header:X-Forwarded-For"],
+ "actions": [
+ {"name": "shell",
+ "params": {"cmd": "iptables -A INPUT -s %v -j DROP", "args": ["Header:X-Forwarded-For"]}}
+ ]
+ }
+ ]
+ },
+ {
+ "name": "log'n'block rss",
+ "interval": 300,
+ "limit": 2500,
+ "filters": ["Path=^/$", "GET:format=rss"],
+ "actions": [
+ {"name": "log"},
+ {"name": "block"}
+ ]
+ },
+ {
+ "name": "log rule",
+ "filters": ["Path=/"],
+ "actions": [ {"name": "log"} ],
+ "subrules": [
+ {
+ "name": "block missing accept-language",
+ "filters": ["!Header:Accept-Language"],
+ "actions": [
+ {"name": "block"}
+ ]
+ },
+ {
+ "name": "block curl",
+ "filters": ["Header:User-Agent=[Cc]url"],
+ "actions": [
+ {"name": "block"}
+ ]
+ }
+ ]
+ }
+]
diff --git a/utils/templates/lib/systemd/system/filtron.service b/utils/templates/lib/systemd/system/filtron.service
new file mode 100644
index 000000000..fdb67731a
--- /dev/null
+++ b/utils/templates/lib/systemd/system/filtron.service
@@ -0,0 +1,29 @@
+[Unit]
+
+Description=${SERVICE_NAME}
+After=syslog.target
+After=network.target
+
+[Service]
+
+Type=simple
+User=${SERVICE_USER}
+Group=${SERVICE_GROUP}
+WorkingDirectory=${SERVICE_HOME}
+ExecStart=${SERVICE_HOME}/go-apps/bin/filtron -rules ${FILTRON_RULES}
+
+Restart=always
+Environment=USER=${SERVICE_USER} HOME=${SERVICE_HOME}
+
+# Some distributions may not support these hardening directives. If you cannot
+# start the service due to an unknown option, comment out the ones not supported
+# by your version of systemd.
+
+ProtectSystem=full
+PrivateDevices=yes
+PrivateTmp=yes
+NoNewPrivileges=true
+
+[Install]
+
+WantedBy=multi-user.target