Why?
I recently had to set up Traefik and Crowdsec on six virtual servers in a row. I decided it was easier to create a script that did all the installation for me, and now I'm sharing it.
Set up a Secure Docker Proxy in Minutes
wget https://raw.githubusercontent.com/MadJalapeno/homelab-traefik/refs/heads/main/install.sh
chmod +x install.sh
./install.sh
Copy and paste that in your terminal. The script checks ports are available, you have docker installed, and then asks for paths, etc before it does anything.
I recently had to set up Traefik and Crowdsec on six virtual servers in a row. I decided it was easier to create a script that did all the installation for me, and now I'm sharing it.
The script installs Traefik as your reverse proxy with automatic HTTPS certificates and integrates CrowdSec for intelligent threat protection. Everything runs in Docker containers.
$ ./install.sh
β Checking Ports
β Checking Docker
β Installing Traefik
β Configuring CrowdSec
β Setting up bouncers
β Generating SSL certificates
All done!
services:
nginx:
image: nginx
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`nginx.example.com`)"
- "traefik.http.routers.nginx.tls.certresolver=letsencrypt"
Traefik handles SSL certificates automatically via Let's Encrypt. Just add labels to your Docker services and certificates are obtained and renewed automatically.
CrowdSec monitors your traffic in real-time, detects malicious behavior, and automatically blocks threats. It shares intelligence with a global community to stay ahead of attackers.
$ cscli decisions list
ββββββββββββββββββββ¬βββββββββββ¬ββββββββββββββββ
β IP β Duration β Reason β
ββββββββββββββββββββΌβββββββββββΌββββββββββββββββ€
β 192.168.1.100 β 4h β bruteforce β
β 10.0.0.50 β 24h β http-probing β
β 172.16.0.10 β 1h β bad-reputationβ
ββββββββββββββββββββ΄βββββββββββ΄ββββββββββββββββ
$ docker ps
CONTAINER ID IMAGE
a1b2c3d4e5f6 traefik:latest
b2c3d4e5f6g7 crowdsec/crowdsec
c3d4e5f6g7h8 crowdsec/traefik-bouncer
$ docker network ls
NETWORK ID NAME
abc123def456 proxy
Three containers work together seamlessly: Traefik routes traffic, CrowdSec analyzes logs, and the bouncer blocks threats. All connected via a dedicated Docker network.
All configuration is stored in simple YAML files. Modify routing rules, add middleware, customize CrowdSec scenarios, or adjust security policies with ease.
$ tree config/
config/
βββ traefik/
β βββ traefik.yml
β βββ conf/
β βββ certs/
βββ crowdsec/
βββ acquis.yaml
βββ scenarios/
βββ custom-rules.yaml
Dashboards:
π· Traefik Dashboard
https://traefik.yourdomain.com
View routers, services, middleware
π‘οΈ CrowdSec Metrics
$ cscli metrics
Decisions, scenarios, parsers
Monitor everything through Traefik's web dashboard and CrowdSec's command-line tools. You can also sign up for more monitoring at https://crowdsec.net.