Skip to content

Commit cf4b6fe

Browse files
committed
add traefik for kubernetes
1 parent f70aaed commit cf4b6fe

File tree

1 file changed

+71
-1
lines changed

1 file changed

+71
-1
lines changed

crowdsec-docs/docs/appsec/quickstart/traefik.mdx

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ In the directory where you persist configuration files, create an `appsec.yaml`
178178

179179
**Steps**
180180

181+
<<<<<<< HEAD
181182
Create a file named `appsec.yaml` with the following content
182183

183184
```yaml title="appsec.yaml"
@@ -217,28 +218,76 @@ In the directory where you store CrowdSec configuration files (for example,
217218
`./crowdsec/acquis.d`, if you’re following the [recommended directory
218219
structure](/u/getting_started/installation/docker#compose), create a file named
219220
appsec.yaml and mount it into the container.
221+
=======
222+
1. Change to the directory where you ran the `docker run` or `docker compose` command.
223+
2. Create a file named `appsec.yaml` in this directory.
224+
3. Add the following content:
225+
>>>>>>> 24c582de (add traefik for kubernetes)
220226

221227
```yaml title="appsec.yaml"
222-
appsec_config: crowdsecurity/appsec-default
228+
appsec_config: crowdsecurity/appsec-desfault
223229
labels:
224230
type: appsec
225231
listen_addr: 0.0.0.0:7422
226232
source: appsec
227233
```
228234

235+
<<<<<<< HEAD
229236
Since CrowdSec runs inside a container, make sure to set listen_addr to 0.0.0.0
230237
(instead of 127.0.0.1) so it listens on the container’s network interface.
231238

232239
Then, update your Docker Compose service to mount the file:
240+
=======
241+
Because CrowdSec runs inside a container, set listen_addr to 0.0.0.0 instead of
242+
127.0.0.1 so it can accept connections from outside the container.
243+
244+
Edit your docker run command to mount the file:
245+
246+
If a crowdsec container is already running, stop/remove it before re-running with the updated mounts.
247+
248+
```bash
249+
docker run -d --name crowdsec \
250+
-v /path/to/original:/etc/crowdsec \
251+
-v ./appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml \
252+
crowdsecurity/crowdsec
253+
```
254+
255+
</TabItem>
256+
257+
<TabItem value="dockerCompose">
258+
259+
In the directory where you persist configuration files, create an appsec.yaml file and mount it into the container.
260+
261+
**Steps**
262+
263+
1. Change to the directory where you ran the docker compose (or docker run) command.
264+
2. Create a file named appsec.yaml in this directory.
265+
3. Add the following content to the `appsec.yaml`
266+
267+
appsec_config: crowdsecurity/appsec-default
268+
labels:
269+
type: appsec
270+
listen_addr: 0.0.0.0:7422
271+
source: appsec
272+
273+
Because CrowdSec runs in a container, set listen_addr to 0.0.0.0 (not 127.0.0.1) so it listens on the container’s network interface.
274+
275+
Mount the file in your Compose service:
276+
>>>>>>> 24c582de (add traefik for kubernetes)
233277
```
234278
services:
235279
crowdsec:
236280
volumes:
281+
<<<<<<< HEAD
237282
- ./crowdsec/acquis.yaml:/etc/crowdsec/acquis.yaml
238283
- logs:/var/log/nginx
239284
- crowdsec-db:/var/lib/crowdsec/data/
240285
- crowdsec-config:/etc/crowdsec/
241286
- ./crowdsec/acquis.d/appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml
287+
=======
288+
- /path/to/original:/etc/crowdsec # or a named volume
289+
- ./appsec.yaml:/etc/crowdsec/acquis.d/appsec.yaml
290+
>>>>>>> 24c582de (add traefik for kubernetes)
242291
```
243292
244293
Once you have updated the compose file to include the volume mount and the updated environment variable, you can restart the container.
@@ -359,11 +408,32 @@ spec:
359408
crowdsecLapiHost: crowdsec-service.crowdsec.svc.cluster.local:8080
360409
crowdsecLapiKey: <shadowed>
361410
htttTimeoutSeconds: 60
411+
<<<<<<< HEAD
412+
=======
413+
forwardedheaderstrustedips:
414+
- 10.0.0.0/8
415+
- 192.168.0.0/16
416+
- 134.209.137.94
417+
- 2a03:b0c0:2:f0::f557:a001
418+
>>>>>>> 24c582de (add traefik for kubernetes)
362419
crowdsecAppsecEnabled: false
363420
crowdsecAppsecHost: crowdsec:7422
364421
crowdsecAppsecFailureBlock: true
365422
crowdsecAppsecUnreachableBlock: true
366423
```
424+
<<<<<<< HEAD
425+
=======
426+
427+
You can still add some route configuration through
428+
[IngressRoute](https://doc.traefik.io/traefik/reference/routing-configuration/kubernetes/crd/http/ingressroute/?utm_source=chatgpt.com)
429+
and attach the middleware to those routes.
430+
</TabItem>
431+
</Tabs>
432+
433+
For more comprehensive documentation on the Traefik Plugin configuration, please
434+
refer to the [official
435+
documentation](https://plugins.traefik.io/plugins/6335346ca4caa9ddeffda116/crowdsec-bouncer-traefik-plugin).
436+
>>>>>>> 24c582de (add traefik for kubernetes)
367437
368438
You can still add some route configuration through
369439
[IngressRoute](https://doc.traefik.io/traefik/reference/routing-configuration/kubernetes/crd/http/ingressroute)

0 commit comments

Comments
 (0)