You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,53 +24,59 @@ import RemediationSupportBadges from '@site/src/components/remediation-support-b
26
24
<RemediationSupportBadges
27
25
/>
28
26
29
-
# cs-fastly-bouncer
27
+
# Fastly bouncer
30
28
31
-
A Remediation Component that syncs the decisions made by CrowdSec with Fastly's VCL. Manages multi account, multi service setup. Supports IP, Country and AS scoped decisions.
32
-
To learn how to setup crowdsec to consume fastly logs see [this](/u/user_guides/consuming_fastly_logs)
29
+
A Remediation Component that syncs the decisions made by CrowdSec with Fastly's VCL. Manages multi account, multi service setup. Supports IP, Range, Country and AS scoped decisions.
30
+
To learn how to set up crowdsec to consume Fastly logs see [this](/u/user_guides/consuming_fastly_logs)
33
31
34
32
35
-
# Installation:
33
+
##Installation
36
34
37
-
## Using pip
35
+
###Using pip
38
36
39
37
Make sure you have python3.8+ installed. Now in a virtual environment run the following:
vim config.yaml # Set crowdsec LAPI key, url, recaptcha keys, logging etc
45
43
crowdsec-fastly-bouncer -c config.yaml # Run it !
46
44
```
47
45
48
-
See how to obtain fastly account tokens [here](https://docs.fastly.com/en/guides/using-api-tokens). The tokens must have write access for the configured services.
46
+
For more details on the config file, see the [Settings](#settings) section below.
49
47
50
-
**Note:** If your bouncer is not installed on the same machine than LAPI, don't forget to set the `lapi_url` and `lapi_key` in the configuration file /etc/crowdsec/bouncers/crowdsec-fastly-bouncer.yaml
48
+
See how to get Fastly account tokens [here](https://docs.fastly.com/en/guides/using-api-tokens). The tokens must have write access for the configured services.
51
49
52
-
**Note:** For captcha to work you must provide the `recaptcha_site_key` and `recaptcha_secret_key` for each service. Learn how [here](http://www.google.com/recaptcha/admin)
50
+
Practically, you can create a Personal token with a Global API access scope, Engineer Role and Automation type.
53
51
52
+
**Note:** If your bouncer is not installed on the same machine as LAPI, remember to set the `lapi_url` and `lapi_key` in the configuration file /etc/crowdsec/bouncers/crowdsec-fastly-bouncer.yaml
54
53
55
-
## Using Docker
54
+
**Note:** For captcha to work, you must provide the `recaptcha_site_key` and `recaptcha_secret_key` for each service. Learn how [here](http://www.google.com/recaptcha/admin)
56
55
57
-
Make sure you have docker or podman installed. In this guide we will use docker, but podman would work as a drop in replacement too.
58
56
59
-
### Initial Setup
57
+
### Using Docker
58
+
59
+
Make sure you have docker or podman installed. In this guide, we will use docker, but podman would work as a drop-in replacement too.
vi cfg.yaml # review config and set `crowdsec_lapi_key`
65
67
touch fastly-cache.json
66
68
```
67
69
70
+
For more details on the config file, see the [Settings](#settings) section below.
71
+
68
72
The `lapi_key` can be obtained by running the following:
69
73
```bash
70
74
sudo cscli -oraw bouncers add fastlybouncer # -oraw flag can discarded for human friendly output.
71
75
```
72
76
73
77
The `lapi_url` must be accessible from the container.
74
78
75
-
### Run the component
79
+
####Run the component
76
80
77
81
```bash
78
82
docker run \
@@ -81,62 +85,286 @@ The `lapi_url` must be accessible from the container.
81
85
crowdsecurity/fastly-bouncer
82
86
```
83
87
84
-
## Activate the new configuration:
88
+
## Usage
89
+
90
+
### Activate the new configuration
91
+
92
+
If you have set `activate: false` for your services in the config file, the bouncer will create a new version of the service with the CrowdSec configuration but will not activate it. This is useful for testing and validation before going live.
93
+
94
+
In this case, after starting the component, go to the Fastly web UI and, for each configured service, review the version created by the bouncer. If everything looks good, you can activate the new configuration.
95
+
96
+
### Version workflow
97
+
98
+
When the bouncer starts for the first time (i.e., when there is no local cache file), it will clone the active version of each configured service (or the version specified in `reference_version` if provided) to create a new draft version. It will then apply the CrowdSec configuration to this draft version.
99
+
100
+
The bouncer will then automatically activate the new version if `activate: true` is set in the config file.
101
+
102
+
103
+
### Maximum items and ACL capacity
104
+
105
+
Bouncer will use the `max_items` parameter in the config file to determine how many decisions can be stored across all ACLs for a service and a decision type (ban or captcha).
106
+
107
+
As each ACL can hold a maximum of 1000 items, it will also determine how many ACLs are needed to accommodate the `max_items` limit.
108
+
109
+
For example, if `max_items` is set to 5000, the bouncer will create up to 10 ACLs in Fastly (5 for `ban`, 5 for `captcha`, each with possibly 1000 items).
110
+
111
+
112
+
## Settings
113
+
114
+
The bouncer configuration is defined in a YAML file that controls all aspects of the bouncer's behavior. Below is a detailed description of each configuration parameter.
115
+
116
+
### Root Configuration Parameters
85
117
86
-
After starting the component, go in the fastly web UI. For each configured service review the version created by the bouncer. If everything looks good, you can activate the new configration !
118
+
#### `bouncer_version`
119
+
-**Type**: String
120
+
-**Default**: Current version of the bouncer
121
+
-**Description**: Version identifier for the bouncer configuration. This is automatically set and should match the installed bouncer version.
-**Description**: Path to the cache file where the bouncer stores the current state of Fastly services and ACLs. This allows the bouncer to resume operations without recreating infrastructure after restarts.
-**Description**: How often (in seconds) the bouncer polls the CrowdSec LAPI for new decisions and updates Fastly ACLs accordingly.
154
+
-**Example**: `update_frequency: 30`
155
+
156
+
### CrowdSec Configuration
157
+
158
+
The `crowdsec_config` section configures the connection and filtering for the CrowdSec Local API (LAPI).
159
+
160
+
#### `lapi_key`
161
+
-**Type**: String (required)
162
+
-**Description**: API key for authenticating with the CrowdSec LAPI. This key is generated when registering the bouncer with CrowdSec.
163
+
-**Example**: `lapi_key: '1234'`
164
+
165
+
#### `lapi_url`
166
+
-**Type**: String
167
+
-**Default**: `http://localhost:8080/`
168
+
-**Description**: URL of the CrowdSec LAPI endpoint.
169
+
-**Example**: `lapi_url: http://localhost:8080/`
170
+
171
+
#### `include_scenarios_containing`
172
+
-**Type**: List of strings
173
+
-**Default**: `[]` (empty list - include all scenarios)
174
+
-**Description**: Only process decisions from scenarios whose names contain any of these strings. Useful for filtering specific types of attacks.
175
+
-**Example**:
176
+
```yaml
177
+
include_scenarios_containing:
178
+
- "ssh"
179
+
- "http"
180
+
```
181
+
182
+
#### `exclude_scenarios_containing`
183
+
- **Type**: List of strings
184
+
- **Default**: `[]` (empty list - exclude no scenarios)
185
+
- **Description**: Exclude decisions from scenarios whose names contain any of these strings. Takes precedence over `include_scenarios_containing`.
186
+
- **Example**:
187
+
```yaml
188
+
exclude_scenarios_containing:
189
+
- "whitelist"
190
+
```
191
+
192
+
#### `only_include_decisions_from`
193
+
- **Type**: List of strings
194
+
- **Default**: `["crowdsec", "cscli"]`
195
+
- **Description**: Only process decisions that originate from these sources. Common sources include `crowdsec` (automatic detection), `cscli` (manual decisions), and `CAPI` (Community API). Let it empty to include decisions from all sources.
196
+
- **Example**:
197
+
```yaml
198
+
only_include_decisions_from:
199
+
- crowdsec
200
+
- cscli
201
+
- CAPI
202
+
```
203
+
204
+
#### `insecure_skip_verify`
205
+
- **Type**: Boolean
206
+
- **Default**: `false`
207
+
- **Description**: Skip TLS certificate verification when connecting to LAPI. Only use for testing or when using self-signed certificates.
208
+
- **Example**: `insecure_skip_verify: false`
209
+
210
+
#### `key_path`
211
+
- **Type**: String
212
+
- **Default**: `""` (empty)
213
+
- **Description**: Path to client TLS key file for mutual TLS authentication with LAPI.
214
+
- **Example**: `key_path: '/path/to/client.key'`
215
+
216
+
#### `cert_path`
217
+
- **Type**: String
218
+
- **Default**: `""` (empty)
219
+
- **Description**: Path to client TLS certificate file for mutual TLS authentication with LAPI.
220
+
- **Example**: `cert_path: '/path/to/client.crt'`
221
+
222
+
#### `ca_cert_path`
223
+
- **Type**: String
224
+
- **Default**: `""` (empty)
225
+
- **Description**: Path to custom CA certificate file for verifying LAPI server certificate.
226
+
- **Example**: `ca_cert_path: '/path/to/ca.crt'`
227
+
228
+
### Fastly Account Configuration
229
+
230
+
The `fastly_account_configs`) section defines one or more Fastly accounts and their associated services. Each account requires a separate API token.
231
+
232
+
#### Account Level Parameters
233
+
234
+
##### `account_token`
235
+
- **Type**: String (required)
236
+
- **Description**: Fastly API token with appropriate permissions to manage services, ACLs, and VCL configurations.
- **Description**: List of Fastly services to protect with CrowdSec decisions.
242
+
243
+
#### Service Level Parameters
244
+
245
+
##### `id`
246
+
- **Type**: String (required)
247
+
- **Description**: Fastly service ID to configure with CrowdSec protection.
248
+
- **Example**: `id: jrLHbDGn9NbOHO7eSH1Xvo`
249
+
250
+
##### `activate`
251
+
- **Type**: Boolean
252
+
- **Default**: `false`
253
+
- **Description**: Whether to automatically activate new service versions with CrowdSec configurations. Set to `true` for production deployment.
254
+
- **Example**: `activate: true`
255
+
256
+
##### `max_items`
257
+
- **Type**: Integer
258
+
- **Default**: `20000`
259
+
- **Description**: Maximum number of IP addresses that can be stored across all ACLs for this service. The bouncer will create multiple ACLs if needed to accommodate this limit.
260
+
- **Example**: `max_items: 5000`
261
+
262
+
##### `recaptcha_site_key`
263
+
- **Type**: String (required)
264
+
- **Description**: Google reCAPTCHA site key for the captcha challenge functionality.
- **Description**: Specific Fastly service version to clone from instead of using the currently active version. Useful for maintaining consistent base configurations.
282
+
- **Example**: `reference_version: 63`
283
+
284
+
285
+
### Example Configuration
286
+
287
+
Below is an example configuration file with all parameters set to their defaults or example values.
89
288
90
289
```yaml
91
290
crowdsec_config:
92
291
lapi_key: ${LAPI_KEY}
93
292
lapi_url: "http://localhost:8080/"
293
+
only_include_decisions_from:
294
+
- crowdsec
295
+
- cscli
296
+
- CAPI
297
+
exclude_scenarios_containing: []
298
+
include_scenarios_containing: ["ssh"]
299
+
ca_cert_path: ''
300
+
cert_path: ''
301
+
insecure_skip_verify: false
302
+
key_path: ''
94
303
95
304
fastly_account_configs:
96
-
- account_token: # Obtain this from fastly
305
+
- account_token: a***********************z # Get this from fastly
97
306
services:
98
-
- id: # The id of the service
99
-
recaptcha_site_key: # Required for captcha support
100
-
recaptcha_secret_key: # Required for captcha support
307
+
- id: a***********************z # The id of the service
308
+
recaptcha_site_key: a***********************z # Required for captcha support
309
+
recaptcha_secret_key: a***********************z # Required for captcha support
101
310
max_items: 20000 # max_items refers to the capacity of IP/IP ranges to ban/captcha.
102
-
activate: false # # Set to true, to activate the new config in production
103
-
reference_version: # version to clone/use
104
-
clone_reference_version: true # whether to clone the "reference_version".
311
+
activate: true # # Set to true, to activate the new config in production
105
312
captcha_cookie_expiry_duration: '1800' # Duration to persist the cookie containing proof of solving captcha
313
+
reference_version: null # Optional: specify a specific version to clone from instead of the active version
106
314
107
-
bouncer_version:
108
-
update_frequency: 10# Duration in seconds to poll the crowdsec API
315
+
bouncer_version: v0.0.2
316
+
update_frequency: 30 # Duration in seconds to poll the crowdsec API
109
317
log_level: info # Valid choices are either of "debug","info","warning","error"
110
318
log_mode: stdout # Valid choices are "file" or "stdout" or "stderr"
111
319
log_file: /var/log/crowdsec-fastly-bouncer.log # Ignore if logging to stdout or stderr
0 commit comments