Skip to content

Commit d5f5cd1

Browse files
committed
add ipv6 docker-compose support
1 parent aa67588 commit d5f5cd1

File tree

5 files changed

+89
-66
lines changed

5 files changed

+89
-66
lines changed

docker-compose.yml

Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ services:
55
context: .
66
dockerfile: ./docker/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
77
networks:
8-
- wordpress_bouncer_network
8+
- wordpress_bouncer_network_ipv4
9+
- wordpress_bouncer_network_ipv6
910
depends_on:
1011
- crowdsec
1112
- mysql
@@ -18,7 +19,7 @@ services:
1819
define('WP_CRON_LOCK_TIMEOUT', 1);
1920
# more here https://hub.docker.com/_/wordpress
2021
ports:
21-
- "8050:80"
22+
- "80:80"
2223
volumes:
2324
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
2425

@@ -27,7 +28,8 @@ services:
2728
context: .
2829
dockerfile: ./docker/wp5.5/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
2930
networks:
30-
- wordpress_bouncer_network
31+
- wordpress_bouncer_network_ipv4
32+
- wordpress_bouncer_network_ipv6
3133
depends_on:
3234
- crowdsec
3335
- mysql
@@ -40,7 +42,7 @@ services:
4042
define('WP_CRON_LOCK_TIMEOUT', 1);
4143
# more here https://hub.docker.com/_/wordpress
4244
ports:
43-
- "8050:80"
45+
- "80:80"
4446
volumes:
4547
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
4648

@@ -49,7 +51,8 @@ services:
4951
context: .
5052
dockerfile: ./docker/wp5.4/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
5153
networks:
52-
- wordpress_bouncer_network
54+
- wordpress_bouncer_network_ipv4
55+
- wordpress_bouncer_network_ipv6
5356
depends_on:
5457
- crowdsec
5558
- mysql
@@ -62,7 +65,7 @@ services:
6265
define('WP_CRON_LOCK_TIMEOUT', 1);
6366
# more here https://hub.docker.com/_/wordpress
6467
ports:
65-
- "8050:80"
68+
- "80:80"
6669
volumes:
6770
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
6871

@@ -71,7 +74,8 @@ services:
7174
context: .
7275
dockerfile: ./docker/wp5.3/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
7376
networks:
74-
- wordpress_bouncer_network
77+
- wordpress_bouncer_network_ipv4
78+
- wordpress_bouncer_network_ipv6
7579
depends_on:
7680
- crowdsec
7781
- mysql
@@ -84,7 +88,7 @@ services:
8488
define('WP_CRON_LOCK_TIMEOUT', 1);
8589
# more here https://hub.docker.com/_/wordpress
8690
ports:
87-
- "8050:80"
91+
- "80:80"
8892
volumes:
8993
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
9094

@@ -93,7 +97,8 @@ services:
9397
context: .
9498
dockerfile: ./docker/wp5.2/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
9599
networks:
96-
- wordpress_bouncer_network
100+
- wordpress_bouncer_network_ipv4
101+
- wordpress_bouncer_network_ipv6
97102
depends_on:
98103
- crowdsec
99104
- mysql
@@ -106,7 +111,7 @@ services:
106111
define('WP_CRON_LOCK_TIMEOUT', 1);
107112
# more here https://hub.docker.com/_/wordpress
108113
ports:
109-
- "8050:80"
114+
- "80:80"
110115
volumes:
111116
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
112117

@@ -115,7 +120,8 @@ services:
115120
context: .
116121
dockerfile: ./docker/wp5.1/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
117122
networks:
118-
- wordpress_bouncer_network
123+
- wordpress_bouncer_network_ipv4
124+
- wordpress_bouncer_network_ipv6
119125
depends_on:
120126
- crowdsec
121127
- mysql
@@ -128,7 +134,7 @@ services:
128134
define('WP_CRON_LOCK_TIMEOUT', 1);
129135
# more here https://hub.docker.com/_/wordpress
130136
ports:
131-
- "8050:80"
137+
- "80:80"
132138
volumes:
133139
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
134140

@@ -137,7 +143,8 @@ services:
137143
context: .
138144
dockerfile: ./docker/wp5.0/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
139145
networks:
140-
- wordpress_bouncer_network
146+
- wordpress_bouncer_network_ipv4
147+
- wordpress_bouncer_network_ipv6
141148
depends_on:
142149
- crowdsec
143150
- mysql
@@ -150,7 +157,7 @@ services:
150157
define('WP_CRON_LOCK_TIMEOUT', 1);
151158
# more here https://hub.docker.com/_/wordpress
152159
ports:
153-
- "8050:80"
160+
- "80:80"
154161
volumes:
155162
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
156163

@@ -159,7 +166,8 @@ services:
159166
context: .
160167
dockerfile: ./docker/wp4.9/php-${CS_WORDPRESS_BOUNCER_PHP_VERSION}.Dockerfile
161168
networks:
162-
- wordpress_bouncer_network
169+
- wordpress_bouncer_network_ipv4
170+
- wordpress_bouncer_network_ipv6
163171
depends_on:
164172
- crowdsec
165173
- mysql
@@ -172,41 +180,47 @@ services:
172180
define('WP_CRON_LOCK_TIMEOUT', 1);
173181
# more here https://hub.docker.com/_/wordpress
174182
ports:
175-
- "8050:80"
183+
- "80:80"
176184
volumes:
177185
- .:/var/www/html/wp-content/plugins/cs-wordpress-bouncer:rw
178186

179187
crowdsec:
180188
image: crowdsecurity/crowdsec:latest
181189
networks:
182-
- wordpress_bouncer_network
190+
- wordpress_bouncer_network_ipv4
191+
- wordpress_bouncer_network_ipv6
183192
environment:
184193
- DISABLE_AGENT=true
185194
ports:
186195
- "8051:8080"
187196
mysql:
188197
image: mysql:5.7
189198
networks:
190-
- wordpress_bouncer_network
199+
- wordpress_bouncer_network_ipv4
200+
- wordpress_bouncer_network_ipv6
191201
environment:
192202
- MYSQL_ROOT_PASSWORD=super_secret_password
193203
- MYSQL_DATABASE=wordpress
194204
redis:
195205
image: redis:6-alpine
196206
networks:
197-
- wordpress_bouncer_network
207+
- wordpress_bouncer_network_ipv4
208+
- wordpress_bouncer_network_ipv6
198209
memcached:
199210
image: memcached:1-alpine
200211
networks:
201-
- wordpress_bouncer_network
212+
- wordpress_bouncer_network_ipv4
213+
- wordpress_bouncer_network_ipv6
202214
wpscan:
203215
image: wpscanteam/wpscan
204216
networks:
205-
- wordpress_bouncer_network
217+
- wordpress_bouncer_network_ipv4
218+
- wordpress_bouncer_network_ipv6
206219
e2e:
207220
image: mcr.microsoft.com/playwright:focal
208221
networks:
209-
- wordpress_bouncer_network
222+
- wordpress_bouncer_network_ipv4
223+
- wordpress_bouncer_network_ipv6
210224
environment:
211225
LAPI_URL_FROM_WP: http://crowdsec:8080
212226
LAPI_URL_FROM_E2E: http://crowdsec:8080
@@ -226,9 +240,16 @@ services:
226240
command: tail -F anything
227241

228242
networks:
229-
wordpress_bouncer_network:
230-
name: wordpress_bouncer_network
231-
enable_ipv6: false
232-
ipam:
233-
config:
234-
- subnet: ${NETWORK_SUBNET}
243+
wordpress_bouncer_network_ipv4:
244+
name: wordpress_bouncer_network_ipv4
245+
enable_ipv6: false
246+
ipam:
247+
config:
248+
- subnet: ${NETWORK_SUBNET}
249+
wordpress_bouncer_network_ipv6:
250+
name: wordpress_bouncer_network
251+
enable_ipv6: true
252+
ipam:
253+
config:
254+
- subnet: 2001:3200:3200::/64
255+
gateway: 2001:3200:3200::1

docs/full-guide.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ We will start using "live" mode. You'll understand what it is after try the stre
1414
docker-compose logs -f crowdsec
1515
```
1616

17-
* In wp-admin, [ensure the bouncer is configured with **live** mode](http://localhost:8050/wp-admin/admin.php?page=crowdsec_plugin) (stream mode disabled).
17+
* In wp-admin, [ensure the bouncer is configured with **live** mode](http://localhost/wp-admin/admin.php?page=crowdsec_plugin) (stream mode disabled).
1818

1919
### Discover the cache system
2020

21-
* In a tab, visit the [public home](http://localhost:8050/). You're allowed because LAPI said your IP is clean.
21+
* In a tab, visit the [public home](http://localhost/). You're allowed because LAPI said your IP is clean.
2222

23-
> To avoid latencies when the clean IP browse the website, the bouncer will keep this information in cache for 30 seconds (you can change this value in the [avdanced settings page](http://localhost:8050/wp-admin/admin.php?page=crowdsec_advanced_settings)). In other words, LAPI will not be requested to check this IP for the next 30 seconds.
23+
> To avoid latencies when the clean IP browse the website, the bouncer will keep this information in cache for 30 seconds (you can change this value in the [avdanced settings page](http://localhost/wp-admin/admin.php?page=crowdsec_advanced_settings)). In other words, LAPI will not be requested to check this IP for the next 30 seconds.
2424
25-
* You can call the website as many times as you want, the cache system will take relay during the ban period and so LAPI will not be disturbed. The ban decision will stay in cache for the full ban duration. Then the [public home](http://localhost:8050/) should be available again.
25+
* You can call the website as many times as you want, the cache system will take relay during the ban period and so LAPI will not be disturbed. The ban decision will stay in cache for the full ban duration. Then the [public home](http://localhost/) should be available again.
2626

2727
### Try ban remediation
2828

29-
* If you want to skip this delay, feel free to [clear the cache in the wp-admin](http://localhost:8050/wp-admin/admin.php?page=crowdsec_plugin).
29+
* If you want to skip this delay, feel free to [clear the cache in the wp-admin](http://localhost/wp-admin/admin.php?page=crowdsec_plugin).
3030

3131
The `DOCKER_HOST_IP` environnement variable is initialized via a call to:
3232

@@ -42,7 +42,7 @@ source ./load-env-vars.sh
4242
docker-compose exec crowdsec cscli decisions add --ip ${DOCKER_HOST_IP} --duration 4h --type ban
4343
```
4444

45-
* Immediately, the [public home](http://localhost:8050/) is now locked with a short message to explain you that you are banned.
45+
* Immediately, the [public home](http://localhost/) is now locked with a short message to explain you that you are banned.
4646

4747
### Try "captcha" remediation
4848

@@ -58,7 +58,7 @@ docker-compose exec crowdsec cscli decisions delete --all
5858
docker-compose exec crowdsec cscli decisions add --ip ${DOCKER_HOST_IP} --duration 15m --type captcha
5959
```
6060

61-
* The [public home](http://localhost:8050/) now request you to fill a captcha.
61+
* The [public home](http://localhost/) now request you to fill a captcha.
6262

6363
* Unless you manage to solve the captcha, you'll not be able to access the website.
6464

@@ -71,7 +71,7 @@ With live mode, as you tried it just before, each time a user arrives to the web
7171

7272
To avoid this, LAPI offers a "stream" mode. The decisions list is updated at a predefined frequency and kept in cache. Let's try it!
7373

74-
> This bouncer uses the WordPress cron system. For demo purposes, we encourage you to [install the WP-Control plugin](http://localhost:8050/wp-admin/plugin-install.php?s=wp-control&tab=search&type=term), a plugin to view and control each Wordpress Cron task jobs.
74+
> This bouncer uses the WordPress cron system. For demo purposes, we encourage you to [install the WP-Control plugin](http://localhost/wp-admin/plugin-install.php?s=wp-control&tab=search&type=term), a plugin to view and control each Wordpress Cron task jobs.
7575
7676
First, clear the previous decisions:
7777

@@ -80,17 +80,17 @@ First, clear the previous decisions:
8080
docker-compose exec crowdsec cscli decisions delete --all
8181
```
8282

83-
* Then enable "stream" mode [right here](http://localhost:8050/wp-admin/admin.php?page=crowdsec_advanced_settings) and set the resync frequency to 30 seconds. If you installed WP-Control plugin, you can see that a new cron tak has just been added here http://localhost:8050/wp-admin/tools.php?page=crontrol_admin_manage_page.
83+
* Then enable "stream" mode [right here](http://localhost/wp-admin/admin.php?page=crowdsec_advanced_settings) and set the resync frequency to 30 seconds. If you installed WP-Control plugin, you can see that a new cron tak has just been added here http://localhost/wp-admin/tools.php?page=crontrol_admin_manage_page.
8484

85-
* As the whole blocklist has just been loaded in cache (0 decision!), your IP is allowed. The [public home](http://localhost:8050/) is available.
85+
* As the whole blocklist has just been loaded in cache (0 decision!), your IP is allowed. The [public home](http://localhost/) is available.
8686

8787
* Now, if you ban your IP for 4h:
8888

8989
```bash
9090
docker-compose exec crowdsec cscli decisions add --ip ${DOCKER_HOST_IP} --duration 4h --type ban
9191
```
9292

93-
* In less than 30 seconds your IP will be banned and the [public home](http://localhost:8050/) will be locked.
93+
* In less than 30 seconds your IP will be banned and the [public home](http://localhost/) will be locked.
9494

9595
Conclusion: with the stream mode, LAPI decisions are fetched on a regular basis rather than being called when user arrives for the first time.
9696

@@ -102,13 +102,13 @@ The docker-compose file started 2 unused containers, redis and memcached.
102102

103103
Let's try **Redis**!
104104

105-
- Just go to the [advanced settings](http://localhost:8050/wp-admin/admin.php?page=crowdsec_advanced_settings) page
105+
- Just go to the [advanced settings](http://localhost/wp-admin/admin.php?page=crowdsec_advanced_settings) page
106106
- select the **Caching technology** named "Redis" and
107107
- type `redis://redis:6379` in the "Redis DSN" field.
108108

109109
Very similar with **Memcached**!
110110

111-
- Just go to the [advanced settings](http://localhost:8050/wp-admin/admin.php?page=crowdsec_advanced_settings) page
111+
- Just go to the [advanced settings](http://localhost/wp-admin/admin.php?page=crowdsec_advanced_settings) page
112112
- select the **Caching technology** named "Memcached" and
113113
- type `memcached://memcached:11211` in the "Memcached DSN" field.
114114

docs/install-with-docker-compose.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Follow this guide to get the development stack installed locally.
66
> - you should have [`docker`](https://docs.docker.com/get-docker/) installed
77
> - `docker` should be [`runnable without sudo`](https://docs.docker.com/engine/install/linux-postinstall/).
88
> - [`docker-compose`](https://docs.docker.com/compose/install/) installed locally.
9+
> - IPv6 should be enable in your docker configuration. Enabled it following [this guide](https://docs.docker.com/config/daemon/ipv6/). (Note that you'll may have to create the file `/etc/docker/daemon.json`).
10+
> - If your develop environnment is MacOS, please refer to the [MacOS host installation guide](macos-host.md).
911
1012
## Install the stack for development purpose
1113

@@ -37,7 +39,7 @@ Alternatively, you can install wordpress and the plugin manually with:
3739
docker-compose up -d wordpress crowdsec mysql redis memcached
3840
```
3941

40-
Then visit the wordpress instance here: http://localhost:8050 and install the wordpress instance.
42+
Then visit the wordpress instance here: http://localhost and install the wordpress instance.
4143

4244
Infos to setup the plugin:
4345

@@ -55,7 +57,7 @@ http://crowdsec:8080
5557

5658
| Info | Value |
5759
|-----------------|--------------------------------------|
58-
| Public blog URL | http://localhost:8050 |
59-
| Blog admin URL | http://localhost:8050/wp-admin |
60+
| Public blog URL | http://localhost |
61+
| Blog admin URL | http://localhost/wp-admin |
6062
| Admin username | `admin` |
6163
| Pasword | `my_very_very_secret_admin_password` |

run-tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ docker-compose exec $CONTAINER_NAME composer install --working-dir /var/www/html
1414
export BOUNCER_KEY=`docker-compose exec crowdsec cscli bouncers add e2e-tests -o raw`
1515
docker-compose exec crowdsec cscli machines add $WATCHER_LOGIN --password $WATCHER_PASSWORD
1616
echo "Waiting for WordPress container to initialize..."
17-
until $(curl --output /dev/null --silent --head --fail http://localhost:8050); do
17+
until $(curl --output /dev/null --silent --head --fail http://localhost); do
1818
printf '.'
1919
sleep 0.1
2020
done
@@ -54,7 +54,7 @@ else
5454
echo "DEBUG MODE ENABLED"
5555
cd tests/e2e && yarn && cd -
5656

57-
WORDPRESS_URL="http://localhost:8050"
57+
WORDPRESS_URL="http://localhost"
5858

5959
WORDPRESS_URL=${WORDPRESS_URL} \
6060
BROWSER_IP=$DOCKER_HOST_IP \

0 commit comments

Comments
 (0)