Skip to content

Commit 7e3de55

Browse files
docs(*): Add configurations docs
1 parent a162e4d commit 7e3de55

File tree

2 files changed

+98
-9
lines changed

2 files changed

+98
-9
lines changed

docs/USER_GUIDE.md

Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,96 @@ echo "\nResult: $remediation\n\n"; // "ban", "captcha" or "bypass"
9292

9393
#### Configurations
9494

95-
Please see the below [Standalone settings](#standalone-settings) paragraph or look at the [Settings example file](../scripts/auto-prepend/settings.example.php) for a description of each available parameter that you can pass to the `configure` method.
95+
You can pass an array of configurations in the `$bouncer->configure($configs)` method.
96+
Please look at the [Settings example file](../scripts/auto-prepend/settings.example.php) for quick overview.
97+
98+
Here is the list of available settings:
99+
100+
##### LAPI Connection
101+
102+
- `api_key`: Key generated by the cscli (CrowdSec cli) command like `cscli bouncers add bouncer-php-library`
103+
104+
- `api_url`: Define the URL to your LAPI server, default to `http://localhost:8080`.
105+
106+
- `api_timeout`: In seconds. The timeout when calling LAPI. Must be greater or equal than 1. Defaults to 1 sec.
107+
- `api_user_agent`: HTTP user agent used to call CLAPI. Default to this library name/current version.
108+
109+
##### Debug
110+
- `debug_mode`:true to enable verbose debug log.
111+
112+
113+
- `log_directory_path`: Absolute path to store log files. Important note: be sur this path won't be publicly accessible
114+
115+
- `display_errors`: true to stop the process and display errors on browser if any.
116+
117+
- `forced_test_ip`: Only for test or debug purpose. Default to empty. If not empty, it will be used for all remediation and geolocation processes.
118+
##### Bouncer behavior
119+
120+
- `bouncing_level`: Select from `bouncing_disabled`, `normal_bouncing` or `flex_bouncing`. Choose if you want to apply CrowdSec directives (Normal bouncing) or be more permissive (Flex bouncing). With the `Flex mode`, it is impossible to accidentally block access to your site to people who don’t deserve it. This mode makes it possible to never ban an IP but only to offer a Captcha, in the worst-case scenario.
121+
122+
- `fallback_remediation`: Select from `bypass` (minimum remediation), `captcha` or `ban` (maximum remediation). Default to 'captcha'. Handle unknown remediations as.
123+
124+
- `max_remediation_level`: Select from `bypass`,`captcha` or `ban`. Default to 'ban'. Cap the
125+
remediation to the selected one.
126+
127+
- `trust_ip_forward_array`: If you use a CDN, a reverse proxy or a load balancer, set an array of IPs. For other IPs, the bouncer will not trust the X-Forwarded-For header.
128+
129+
##### Cache
130+
131+
- `cache_system`: Select from `phpfs` (File system cache), `redis` or `memcached`.
132+
133+
- `fs_cache_path`: Will be used only if you choose File system as cache_system. Important note: be sur this path
134+
won't be publicly accessible.
135+
136+
- `redis_dsn`: Will be used only if you choose Redis cache as cache_system
137+
138+
- `memcached_dsn`: Will be used only if you choose Memcached as cache_system
139+
140+
- `cache_expiration_for_clean_ip`: Set the duration we keep in cache the fact that an IP is clean. In seconds. Defaults to 5.
141+
142+
- `cache_expiration_for_bad_ip`: Set the duration we keep in cache the fact that an IP is bad. In seconds. Defaults to 20.
143+
144+
- `stream_mode`: true to enable stream mode, false to enable the live mode. Default to false. By default, the `live mode` is enabled. The first time a stranger connects to your website, this mode means that the IP will be checked directly by the CrowdSec API. The rest of your user’s browsing will be even more transparent thanks to the fully customizable cache system. But you can also activate the `stream mode`. This mode allows you to constantly feed the bouncer with the malicious IP list via a background task (CRON), making it to be even faster when checking the IP of your visitors. Besides, if your site has a lot of unique visitors at the same time, this will not influence the traffic to the API of your CrowdSec instance.
145+
146+
##### Geolocation
147+
148+
- `geolocation`: Settings for geolocation remediation (i.e. country based remediation).
149+
- `geolocation[enabled]`: true to enable remediation based on country. Default to false.
150+
- `geolocation[type]`: Geolocation system. Only 'maxmind' is available for the moment. Default to `maxmind`
151+
152+
- `geolocation[save_in_session]`: true to store the geolocalized country in session. Default to true. Setting true
153+
will avoid multiple call to the geolocalized system (e.g. maxmind database)
154+
- `geolocation[maxmind]`: MaxMind settings
155+
- `geolocation[maxmind][database_type]`: Select from `country` or `city`. Default to `country`. These are the two available MaxMind database types.
156+
- `geolocation[maxmind][database_path]`: Absolute path to the MaxMind database (mmdb
157+
158+
159+
##### Captcha and ban wall settings
160+
161+
- `hide_mentions`: true to hide CrowdSec mentions on ban and captcha walls.
162+
- Wording and css settings:
163+
164+
`theme_color_text_primary`
165+
`theme_color_text_secondary`
166+
`theme_color_text_button`
167+
`theme_color_text_error_message`
168+
`theme_color_background_page`
169+
`theme_color_background_container`
170+
`theme_color_background_button`
171+
`theme_color_background_button_hover`
172+
`theme_custom_css`
173+
`theme_text_captcha_wall_tab_title`
174+
`theme_text_captcha_wall_title`
175+
`theme_text_captcha_wall_subtitle`
176+
`theme_text_captcha_wall_refresh_image_link`
177+
`theme_text_captcha_wall_captcha_placeholder`
178+
`theme_text_captcha_wall_send_button`
179+
`theme_text_captcha_wall_error_message`
180+
`theme_text_captcha_wall_footer`
181+
`theme_text_ban_wall_tab_title`
182+
`theme_text_ban_wall_title`
183+
`theme_text_ban_wall_subtitle`
184+
`theme_text_ban_wall_footer`
96185

97186

98187
#### The `Standalone` example
@@ -197,22 +286,22 @@ Once you have created the `scripts/auto-prepend/settings.php` file, you have to
197286
```php
198287
use CrowdSecBouncer\Constants;
199288
$crowdSecStandaloneBouncerConfig = [
200-
/** The bouncer api key to access LAPI or CAPI.
289+
/** The bouncer api key to access LAPI.
201290
*
202291
* Key generated by the cscli (CrowdSec cli) command like "cscli bouncers add bouncer-php-library"
203292
*/
204293
'api_key'=> 'YOUR_BOUNCER_API_KEY',
205294

206-
/** Define the URL to your LAPI server, default to CAPI URL.
295+
/** Define the URL to your LAPI server, default to http://localhost:8080.
207296
*
208297
* If you have installed the CrowdSec agent on your server, it should be "http://localhost:8080"
209298
*/
210299
'api_url'=> Constants::DEFAULT_LAPI_URL,
211300

212-
// In seconds. The timeout when calling CAPI/LAPI. Must be greater or equal than 1. Defaults to 1 sec.
301+
// In seconds. The timeout when calling LAPI. Must be greater or equal than 1. Defaults to 1 sec.
213302
'api_timeout'=> 1,
214303

215-
// HTTP user agent used to call CAPI or LAPI. Default to this library name/current version.
304+
// HTTP user agent used to call LAPI. Default to this library name/current version.
216305
'api_user_agent'=> 'CrowdSec PHP Library/x.x.x',
217306

218307
// true to enable verbose debug log.

scripts/auto-prepend/settings.example.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
use CrowdSecBouncer\Constants;
44

55
$crowdSecStandaloneBouncerConfig = [
6-
/** The bouncer api key to access LAPI or CAPI.
6+
/** The bouncer api key to access LAPI.
77
*
88
* Key generated by the cscli (CrowdSec cli) command like "cscli bouncers add bouncer-php-library"
99
*/
1010
'api_key'=> 'YOUR_BOUNCER_API_KEY',
1111

12-
/** Define the URL to your LAPI server, default to CAPI URL.
12+
/** Define the URL to your LAPI server, default to http://localhost:8080.
1313
*
1414
* If you have installed the CrowdSec agent on your server, it should be "http://localhost:8080"
1515
*/
1616
'api_url'=> Constants::DEFAULT_LAPI_URL,
1717

18-
// In seconds. The timeout when calling CAPI/LAPI. Must be greater or equal than 1. Defaults to 1 sec.
18+
// In seconds. The timeout when calling LAPI. Must be greater or equal than 1. Defaults to 1 sec.
1919
'api_timeout'=> 1,
2020

21-
// HTTP user agent used to call CAPI or LAPI. Default to this library name/current version.
21+
// HTTP user agent used to call LAPI. Default to this library name/current version.
2222
'api_user_agent'=> 'CrowdSec PHP Library/x.x.x',
2323

2424
// true to enable verbose debug log.

0 commit comments

Comments
 (0)