Skip to content

Commit e289fbb

Browse files
authored
Merge pull request #6 from meshcloud/feature/docker-compose
Feature/docker compose
2 parents b12e44d + 5c1a1f9 commit e289fbb

File tree

4 files changed

+69
-30
lines changed

4 files changed

+69
-30
lines changed

Caddyfile

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
# Global options
32
order coraza_waf first
43
}
54

@@ -9,25 +8,30 @@
98
respond "WAF-UI-OK" 200
109
}
1110

11+
# Handle WebSocket paths without WAF
12+
handle /ws/* {
13+
reverse_proxy localhost:9001 {
14+
header_up Host {http.request.host}
15+
header_up X-Real-IP {remote}
16+
header_up X-Forwarded-For {remote}
17+
header_up X-Forwarded-Proto {scheme}
18+
header_up Connection {http.request.header.connection}
19+
header_up Upgrade {http.request.header.upgrade}
20+
header_up Sec-WebSocket-Key {http.request.header.sec-websocket-key}
21+
header_up Sec-WebSocket-Version {http.request.header.sec-websocket-version}
22+
transport http {
23+
read_timeout 300s
24+
dial_timeout 300s
25+
}
26+
}
27+
}
28+
1229
route {
1330
coraza_waf {
14-
load_owasp_crs
15-
31+
load_owasp_crs
1632
directives `
17-
# Step 1: Initialize TX collection
1833
SecAction "id:1,phase:1,pass,nolog,initcol:tx=tx"
19-
20-
# Step 2: Initialize TX variable
2134
SecAction "id:2,phase:1,pass,nolog,setvar:tx.bucket_ops=0"
22-
23-
# Allow WebSocket connections for MinIO console
24-
SecRule REQUEST_HEADERS:Upgrade "@streq websocket" "id:1001,phase:1,pass,msg:'Allow WebSocket upgrade requests'"
25-
26-
# Block DELETE on /minio/admin (except WebSocket connections)
27-
SecRule REQUEST_URI "@beginsWith /minio/admin" "id:1002,phase:1,deny,status:403,msg:'MinIO Admin API Access Blocked',chain"
28-
SecRule REQUEST_HEADERS:Upgrade "!@streq websocket"
29-
30-
# Rate limiting
3135
SecRule REQUEST_METHOD "@rx ^(PUT|POST|DELETE)$" "id:1003,phase:1,pass,msg:'Bucket operation',setvar:tx.bucket_ops=+1,expirevar:tx.bucket_ops=60"
3236
SecRule TX:bucket_ops "@gt 50" "id:1004,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'"
3337
`
@@ -38,7 +42,6 @@
3842
header_up X-Real-IP {remote}
3943
header_up X-Forwarded-For {remote}
4044
header_up X-Forwarded-Proto {scheme}
41-
4245
header_up Connection {http.request.header.connection}
4346
header_up Upgrade {http.request.header.upgrade}
4447
header_up Sec-WebSocket-Key {http.request.header.sec-websocket-key}
@@ -65,19 +68,11 @@
6568

6669
route {
6770
coraza_waf {
68-
load_owasp_crs
69-
71+
load_owasp_crs
7072
directives `
71-
# Step 1: Initialize TX collection
7273
SecAction "id:10,phase:1,pass,nolog,initcol:tx=tx"
73-
74-
# Step 2: Initialize TX variable
7574
SecAction "id:11,phase:1,pass,nolog,setvar:tx.bucket_ops=0"
76-
77-
# Log DELETE operations
7875
SecRule REQUEST_METHOD "@streq DELETE" "id:2001,phase:1,log,msg:'DELETE operation logged'"
79-
80-
# Rate limiting
8176
SecRule REQUEST_METHOD "@rx ^(PUT|POST|DELETE)$" "id:2002,phase:1,pass,msg:'Bucket operation',setvar:tx.bucket_ops=+1,expirevar:tx.bucket_ops=60"
8277
SecRule TX:bucket_ops "@gt 50" "id:2003,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'"
8378
`
@@ -86,7 +81,6 @@
8681
reverse_proxy localhost:9000 {
8782
header_up Connection {http.request.header.connection}
8883
header_up Upgrade {http.request.header.upgrade}
89-
9084
}
9185
}
9286

README-coraza.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ A modern Web Application Firewall built with [Coraza](https://coraza.io) and [Ca
66

77
-**OWASP Core Rule Set v4** - Latest security rules
88
-**Multi-backend routing** - Single WAF protects MinIO UI + API
9-
-**Automatic HTTPS** - TLS termination included
109
-**Security headers** - Production-ready security configuration
1110
-**Health checks** - Built-in monitoring endpoints
1211
-**Rate limiting** - API protection against abuse
@@ -45,8 +44,8 @@ docker run -d \
4544
## Architecture
4645

4746
```
48-
Internet → Caddy WAF (8443) → MinIO UI (9001)
49-
→ MinIO API (9000)
47+
Caddy WAF (8080) → MinIO UI (9001)
48+
(8081) → MinIO API (9000)
5049
```
5150

5251
### Request Routing
@@ -66,7 +65,6 @@ Internet → Caddy WAF (8443) → MinIO UI (9001)
6665
- Rate limiting (100 req/min per IP for API endpoints)
6766

6867
### Custom MinIO Rules
69-
- Blocks access to `/minio/admin` endpoints
7068
- Logs all DELETE operations for audit
7169
- Rate limits API endpoints
7270

docker-compose.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
version: '3.8'
2+
services:
3+
minio:
4+
image: quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z
5+
container_name: minio
6+
command: server /data --console-address ":9001" --address ":9000"
7+
environment:
8+
- MINIO_ROOT_USER=minioadmin
9+
- MINIO_ROOT_PASSWORD=your-password
10+
ports:
11+
- "9000:9000"
12+
- "9001:9001"
13+
volumes:
14+
- minio-data:/data
15+
networks:
16+
- minio-net
17+
18+
coraza-waf:
19+
image: coraza-waf-local:latest
20+
container_name: coraza-waf
21+
ports:
22+
- "8080:8080"
23+
- "8081:8081"
24+
depends_on:
25+
- minio
26+
networks:
27+
- minio-net
28+
29+
volumes:
30+
minio-data:
31+
32+
networks:
33+
minio-net:
34+
driver: bridge

main.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,5 +465,18 @@ resource "azurerm_container_group" "minio_aci_container_group" {
465465
timeout_seconds = 3
466466
failure_threshold = 3
467467
}
468+
# The Caddyfile is included as part of the container build.
469+
# If you are testing or want to use a different configuration, you can provide your own
470+
# volume {
471+
# name = "caddyfile"
472+
# mount_path = "/etc/caddy"
473+
# read_only = true
474+
475+
# secret = {
476+
# "Caddyfile" = base64encode(templatefile("${path.module}/Caddyfile.working.tpl", {
477+
# }))
478+
# }
479+
# }
480+
468481
}
469482
}

0 commit comments

Comments
 (0)