Skip to content

Commit ba93672

Browse files
committed
docs: add docker-compose.local.yml and docker-compose.yml
Development usage and prod usage
1 parent 0c658f2 commit ba93672

File tree

3 files changed

+59
-52
lines changed

3 files changed

+59
-52
lines changed

README.md

+15-50
Original file line numberDiff line numberDiff line change
@@ -12,72 +12,37 @@ Traefik plugin to proxy requests to [owasp/modsecurity-crs](https://hub.docker.c
1212

1313
- [Traefik Modsecurity Plugin](#traefik-modsecurity-plugin)
1414
- [Demo](#demo)
15-
- [Full Configuration with docker-compose](#full-configuration-with-docker-compose)
16-
- [How ?](#how-)
15+
- [Usage (docker-compose.yml)](#usage-docker-composeyml)
16+
- [How it works](#how-it-works)
17+
- [Local development (docker-compose.local.yml)](#local-development-docker-composelocalyml)
1718

1819
## Demo
1920

2021
Demo with WAF intercepting relative access in query param.
2122

2223
![Demo](./img/waf.gif)
2324

24-
## Full Configuration with docker-compose
25-
26-
```yml
27-
version: "3.7"
28-
29-
services:
30-
traefik:
31-
image: traefik
32-
ports:
33-
- "8000:80"
34-
- "8080:8080"
35-
command:
36-
- --api.dashboard=true
37-
- --api.insecure=true
38-
- --pilot.token=$TRAEFIK_PILOT_TOKEN
39-
- --experimental.localPlugins.traefik-modsecurity-plugin.moduleName=github.com/acouvreur/traefik-modsecurity-plugin
40-
- --providers.docker=true
41-
- --entrypoints.http.address=:80
42-
volumes:
43-
- '/var/run/docker.sock:/var/run/docker.sock'
44-
- '.:/plugins-local/src/github.com/acouvreur/traefik-modsecurity-plugin'
45-
environment:
46-
- TRAEFIK_PILOT_TOKEN
47-
labels:
48-
- traefik.enable=true
49-
- traefik.http.services.traefik.loadbalancer.server.port=8080
50-
- traefik.http.middlewares.waf.plugin.traefik-modsecurity-plugin.modSecurityUrl=http://waf:80
51-
52-
waf:
53-
image: owasp/modsecurity-crs:apache
54-
environment:
55-
- PARANOIA=1
56-
- ANOMALY_INBOUND=10
57-
- ANOMALY_OUTBOUND=5
58-
- BACKEND=http://dummy
59-
60-
dummy:
61-
image: containous/whoami
62-
63-
website:
64-
image: containous/whoami
65-
labels:
66-
- traefik.enable=true
67-
- traefik.http.routers.website.rule=PathPrefix(`/website`)
68-
- traefik.http.routers.website.middlewares=waf@docker
69-
```
25+
## Usage (docker-compose.yml)
26+
27+
See [docker-compose.yml](docker-compose.yml)
7028

7129
1. docker-compose up
7230
2. Go to http://localhost:8000/website, the request is received without warnings
7331
3. Go to http://localhost:8000/website?test=../etc, the request is intercepted and returned with 403 Forbidden by owasp/modsecurity
7432

75-
## How ?
33+
## How it works
7634

7735
This is a very simple plugin that proxies the query to the owasp/modsecurity apache container.
7836

7937
The plugin checks that the response from the waf container hasn't an http code > 400 before forwarding the request to the real service.
8038

8139
If it is > 400, then the error page is returned instead.
8240

83-
The *dummy* service is created so the waf container forward the request to a service and respond with 200 OK all the time.
41+
The *dummy* service is created so the waf container forward the request to a service and respond with 200 OK all the time.
42+
43+
44+
## Local development (docker-compose.local.yml)
45+
46+
See [docker-compose.local.yml](docker-compose.local.yml)
47+
48+
`docker-compose -f docker-compose.local.yml up` to load the local plugin

docker-compose.local.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: "3.7"
2+
3+
services:
4+
traefik:
5+
image: traefik
6+
ports:
7+
- "8000:80"
8+
- "8080:8080"
9+
command:
10+
- --api.dashboard=true
11+
- --api.insecure=true
12+
- --pilot.token=$TRAEFIK_PILOT_TOKEN
13+
- --experimental.localPlugins.traefik-modsecurity-plugin.moduleName=github.com/acouvreur/traefik-modsecurity-plugin
14+
- --providers.docker=true
15+
- --entrypoints.http.address=:80
16+
volumes:
17+
- '/var/run/docker.sock:/var/run/docker.sock'
18+
- '.:/plugins-local/src/github.com/acouvreur/traefik-modsecurity-plugin'
19+
environment:
20+
- TRAEFIK_PILOT_TOKEN
21+
labels:
22+
- traefik.enable=true
23+
- traefik.http.services.traefik.loadbalancer.server.port=8080
24+
- traefik.http.middlewares.waf.plugin.traefik-modsecurity-plugin.modSecurityUrl=http://waf:80
25+
26+
waf:
27+
image: owasp/modsecurity-crs:apache
28+
environment:
29+
- PARANOIA=1
30+
- ANOMALY_INBOUND=10
31+
- ANOMALY_OUTBOUND=5
32+
- BACKEND=http://dummy
33+
34+
dummy:
35+
image: containous/whoami
36+
37+
website:
38+
image: containous/whoami
39+
labels:
40+
- traefik.enable=true
41+
- traefik.http.routers.website.rule=PathPrefix(`/website`)
42+
- traefik.http.routers.website.middlewares=waf@docker

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ services:
1010
- --api.dashboard=true
1111
- --api.insecure=true
1212
- --pilot.token=$TRAEFIK_PILOT_TOKEN
13-
- --experimental.localPlugins.traefik-modsecurity-plugin.moduleName=github.com/acouvreur/traefik-modsecurity-plugin
13+
- --experimental.plugins.traefik-modsecurity-plugin.modulename=github.com/acouvreur/traefik-modsecurity-plugin
14+
- --experimental.plugins.traefik-modsecurity-plugin.version=v1.0.1
1415
- --providers.docker=true
1516
- --entrypoints.http.address=:80
1617
volumes:
1718
- '/var/run/docker.sock:/var/run/docker.sock'
18-
- '.:/plugins-local/src/github.com/acouvreur/traefik-modsecurity-plugin'
1919
environment:
2020
- TRAEFIK_PILOT_TOKEN
2121
labels:

0 commit comments

Comments
 (0)