Compare commits

...

4 Commits

Author SHA1 Message Date
a5d6d9cbe9 readme 2024-11-10 14:27:39 +01:00
c339dcf62a build tools 2024-11-10 14:27:32 +01:00
45a3644fb8 add bin_path: /bouncer.sh to the static config 2024-11-10 14:27:21 +01:00
e2876851bf add missing "" 2024-11-10 14:08:38 +01:00
6 changed files with 53 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.vscode/

View File

@@ -27,6 +27,7 @@ COPY --from=build-stage /app/cs-custom-bouncer/crowdsec-custom-bouncer \
COPY --from=build-stage /app/cs-custom-bouncer/config/crowdsec-custom-bouncer.yaml \
/crowdsec-custom-bouncer.yaml
ADD --chmod=770 bouncer.sh /bouncer.sh
RUN echo "bin_path: /bouncer.sh" >> /crowdsec-custom-bouncer.yaml
#prometheus port
LABEL me.ar2000.gitea.buildargs.iptablesmode="${IPTABLES_MODE}"
CMD ["/usr/bin/crowdsec-custom-bouncer", "-c", "/crowdsec-custom-bouncer.yaml"]

42
README.md Normal file
View File

@@ -0,0 +1,42 @@
# crowdsec-legacy-firrewall-bouncer
A Crowdsec firewall bouncer based on [crowdsec-custom-bouncer](https://github.com/crowdsecurity/cs-custom-bouncer) aimed at systems without support for `ipset`.
## Tags :
- [gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:latest](https://gitea.ar2000.me/AR2000/-/packages/container/crowdsec-legacy-firewall-bouncer/latest) : `iptables-legacy`
- [gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy](https://gitea.ar2000.me/AR2000/-/packages/container/crowdsec-legacy-firewall-bouncer/legacy) : `iptables-legacy`
- [gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:nft](https://gitea.ar2000.me/AR2000/-/packages/container/crowdsec-legacy-firewall-bouncer/nft) : `iptables-nft`
## Environment variables :
- `IPTABLES_COMMENT` : if set, iptables will load the `comment` module and use the reason argument passed by [crowdsec-custom-bouncer](https://github.com/crowdsecurity/cs-custom-bouncer) as the comment
- `IPTABLES_INSERT` : insert new firewall rules at a fixed position
- `API_KEY` : crowdsec api key
## Configuration :
Set your custom configuration in the `crowdsec-custom-bouncer.yaml.local` file and mount it as a volume at the root of the container. See [Overriding values](https://docs.crowdsec.net/docs/next/configuration/crowdsec_configuration/#overriding-values) or [bouncers/custom](https://docs.crowdsec.net/u/bouncers/custom) for information about the configuration.
### Example configuration :
```yaml
log_mode: stdout
scenarios_containing: ["ssh"]
origins: ["cscli", "crowdsec"]
supported_decisions_types:
- ban
```
## Docker compose :
```yaml
services:
cs-firewall-bouncer:
image: gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy
restart: unless-stopped
environment:
- IPTABLES_INSERT=3
- IPTABLES_COMMENT=true
cap_add:
# allow modification of host's iptable
- NET_ADMIN
- NET_RAW
network_mode: "host"
volumes:
- ./crowdsec-custom-bouncer.yaml.local:/crowdsec-custom-bouncer.yaml.local #load custom config values
```

2
bouncer.sh Normal file → Executable file
View File

@@ -2,7 +2,7 @@
#
# Script to add /remove IPs to iptables
[[ -z "${IPTABLES_COMMENT}" ]] && commment="-m comment --comment $4" || comment=""
[[ -z "${IPTABLES_COMMENT}" ]] && commment="-m comment --comment \"$4\"" || comment=""
function iptableAdd () {
if [[ -z "${IPTABLES_INSERT}" ]]; then

4
build.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
docker build --build-arg IPTABLES_MODE=nft -t gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:nft .
docker build --build-arg IPTABLES_MODE=legacy -t gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy .
docker image tag gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:latest

4
publish.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
docker push gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:nft
docker push gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:legacy
docker push gitea.ar2000.me/ar2000/crowdsec-legacy-firewall-bouncer:latest