|
| 1 | +{ |
| 2 | + order coraza_waf first |
| 3 | + auto_https disable_redirects |
| 4 | +} |
| 5 | + |
| 6 | +# --- WAF for MinIO UI (port 8080) --- |
| 7 | +:8080 { |
| 8 | + handle /health { |
| 9 | + respond "WAF-UI-OK" 200 |
| 10 | + } |
| 11 | + |
| 12 | + # Handle WebSocket paths without WAF |
| 13 | + handle /ws/* { |
| 14 | + reverse_proxy localhost:9001 { |
| 15 | + header_up Host {http.request.host} |
| 16 | + header_up X-Real-IP {remote} |
| 17 | + header_up X-Forwarded-For {remote} |
| 18 | + header_up X-Forwarded-Proto {scheme} |
| 19 | + header_up Connection {http.request.header.connection} |
| 20 | + header_up Upgrade {http.request.header.upgrade} |
| 21 | + header_up Sec-WebSocket-Key {http.request.header.sec-websocket-key} |
| 22 | + header_up Sec-WebSocket-Version {http.request.header.sec-websocket-version} |
| 23 | + transport http { |
| 24 | + read_timeout 300s |
| 25 | + dial_timeout 300s |
| 26 | + } |
| 27 | + } |
| 28 | + } |
| 29 | + |
| 30 | + route { |
| 31 | + coraza_waf { |
| 32 | + load_owasp_crs |
| 33 | + directives ` |
| 34 | + SecAction "id:1,phase:1,pass,nolog,initcol:tx=tx" |
| 35 | + SecAction "id:2,phase:1,pass,nolog,setvar:tx.bucket_ops=0" |
| 36 | + 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" |
| 37 | + SecRule TX:bucket_ops "@gt 50" "id:1004,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'" |
| 38 | + ` |
| 39 | + } |
| 40 | + |
| 41 | + reverse_proxy localhost:9001 { |
| 42 | + header_up Host {http.request.host} |
| 43 | + header_up X-Real-IP {remote} |
| 44 | + header_up X-Forwarded-For {remote} |
| 45 | + header_up X-Forwarded-Proto {scheme} |
| 46 | + header_up Connection {http.request.header.connection} |
| 47 | + header_up Upgrade {http.request.header.upgrade} |
| 48 | + header_up Sec-WebSocket-Key {http.request.header.sec-websocket-key} |
| 49 | + header_up Sec-WebSocket-Version {http.request.header.sec-websocket-version} |
| 50 | + transport http { |
| 51 | + read_timeout 300s |
| 52 | + dial_timeout 300s |
| 53 | + } |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + log { |
| 58 | + output stdout |
| 59 | + format json |
| 60 | + level INFO |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +# --- Keycloak Proxy HTTP (port 8082) --- |
| 65 | +:8082 { |
| 66 | + reverse_proxy localhost:8083 { |
| 67 | + header_up Host {http.request.host} |
| 68 | + header_up X-Real-IP {remote} |
| 69 | + header_up X-Forwarded-For {remote} |
| 70 | + header_up X-Forwarded-Proto https |
| 71 | + header_up X-Forwarded-Host {http.request.host} |
| 72 | + header_up X-Forwarded-Port 8444 |
| 73 | + header_up Accept-Encoding identity |
| 74 | + } |
| 75 | + |
| 76 | + replace { |
| 77 | + "http://localhost:8083" "https://testminio.germanywestcentral.cloudapp.azure.com:8444" |
| 78 | + } |
| 79 | + |
| 80 | + log { |
| 81 | + output stdout |
| 82 | + format json |
| 83 | + level INFO |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +# --- WAF for MinIO API (port 8081) --- |
| 88 | +:8081 { |
| 89 | + handle /health { |
| 90 | + respond "WAF-API-OK" 200 |
| 91 | + } |
| 92 | + |
| 93 | + route { |
| 94 | + coraza_waf { |
| 95 | + load_owasp_crs |
| 96 | + directives ` |
| 97 | + SecAction "id:10,phase:1,pass,nolog,initcol:tx=tx" |
| 98 | + SecAction "id:11,phase:1,pass,nolog,setvar:tx.bucket_ops=0" |
| 99 | + SecRule REQUEST_METHOD "@streq DELETE" "id:2001,phase:1,log,msg:'DELETE operation logged'" |
| 100 | + 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" |
| 101 | + SecRule TX:bucket_ops "@gt 50" "id:2003,phase:1,deny,status:429,msg:'Bucket operation rate limit exceeded'" |
| 102 | + ` |
| 103 | + } |
| 104 | + |
| 105 | + reverse_proxy localhost:9000 { |
| 106 | + header_up Connection {http.request.header.connection} |
| 107 | + header_up Upgrade {http.request.header.upgrade} |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + log { |
| 112 | + output stdout |
| 113 | + format json |
| 114 | + level INFO |
| 115 | + } |
| 116 | +} |
0 commit comments