Last active
May 30, 2025 10:53
-
-
Save korteke/8139bd06984a24934f368d915f0d9165 to your computer and use it in GitHub Desktop.
Traefik + ModSecurity plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: "3.8" | |
| services: | |
| traefik: | |
| image: traefik | |
| ports: | |
| - "8000:80" | |
| - "8080:8080" | |
| command: | |
| - --api.dashboard=true | |
| - --api.insecure=true | |
| - --experimental.plugins.traefik-modsecurity-plugin.modulename=github.com/acouvreur/traefik-modsecurity-plugin | |
| - --experimental.plugins.traefik-modsecurity-plugin.version=v1.3.0 | |
| - --providers.docker=true | |
| - --entrypoints.http.address=:80 | |
| volumes: | |
| - '/var/run/docker.sock:/var/run/docker.sock' | |
| labels: | |
| - traefik.enable=true | |
| - traefik.http.services.traefik.loadbalancer.server.port=8080 | |
| - traefik.http.middlewares.waf.plugin.traefik-modsecurity-plugin.modSecurityUrl=http://waf:80 | |
| - traefik.http.middlewares.waf.plugin.traefik-modsecurity-plugin.maxBodySize=10485760 | |
| # Nginx server with OWASP CRS (Core Rule Set) rules | |
| waf: | |
| image: owasp/modsecurity-crs:nginx-alpine | |
| environment: | |
| - PARANOIA=2 | |
| - ANOMALY_INBOUND=10 | |
| - ANOMALY_OUTBOUND=5 | |
| - BACKEND=http://dummy | |
| # Dummy service that always returns status HTTP 200 to WAF container | |
| dummy: | |
| image: traefik/whoami | |
| # Actual service that we want to protect | |
| website: | |
| image: traefik/whoami | |
| labels: | |
| - traefik.enable=true | |
| - traefik.http.routers.website.rule=PathPrefix(`/`) | |
| - traefik.http.routers.website.middlewares=waf@docker |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment