|
1 | 1 | { |
2 | | - # Global options |
3 | 2 | order coraza_waf first |
4 | 3 | } |
5 | 4 |
|
|
9 | 8 | respond "WAF-UI-OK" 200 |
10 | 9 | } |
11 | 10 |
|
| 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 | + |
12 | 29 | route { |
13 | 30 | coraza_waf { |
14 | | - load_owasp_crs |
15 | | - |
| 31 | + load_owasp_crs |
16 | 32 | directives ` |
17 | | - # Step 1: Initialize TX collection |
18 | 33 | SecAction "id:1,phase:1,pass,nolog,initcol:tx=tx" |
19 | | -
|
20 | | - # Step 2: Initialize TX variable |
21 | 34 | 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 |
31 | 35 | 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" |
32 | 36 | SecRule TX:bucket_ops "@gt 50" "id:1004,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'" |
33 | 37 | ` |
|
38 | 42 | header_up X-Real-IP {remote} |
39 | 43 | header_up X-Forwarded-For {remote} |
40 | 44 | header_up X-Forwarded-Proto {scheme} |
41 | | - |
42 | 45 | header_up Connection {http.request.header.connection} |
43 | 46 | header_up Upgrade {http.request.header.upgrade} |
44 | 47 | header_up Sec-WebSocket-Key {http.request.header.sec-websocket-key} |
|
65 | 68 |
|
66 | 69 | route { |
67 | 70 | coraza_waf { |
68 | | - load_owasp_crs |
69 | | - |
| 71 | + load_owasp_crs |
70 | 72 | directives ` |
71 | | - # Step 1: Initialize TX collection |
72 | 73 | SecAction "id:10,phase:1,pass,nolog,initcol:tx=tx" |
73 | | -
|
74 | | - # Step 2: Initialize TX variable |
75 | 74 | SecAction "id:11,phase:1,pass,nolog,setvar:tx.bucket_ops=0" |
76 | | -
|
77 | | - # Log DELETE operations |
78 | 75 | SecRule REQUEST_METHOD "@streq DELETE" "id:2001,phase:1,log,msg:'DELETE operation logged'" |
79 | | -
|
80 | | - # Rate limiting |
81 | 76 | 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" |
82 | 77 | SecRule TX:bucket_ops "@gt 50" "id:2003,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'" |
83 | 78 | ` |
|
86 | 81 | reverse_proxy localhost:9000 { |
87 | 82 | header_up Connection {http.request.header.connection} |
88 | 83 | header_up Upgrade {http.request.header.upgrade} |
89 | | - |
90 | 84 | } |
91 | 85 | } |
92 | 86 |
|
|
0 commit comments