Skip to content

Commit 4a7cf54

Browse files
committed
adding: merge minio dockerfile
adding: merge minio dockerfile
1 parent c9a0357 commit 4a7cf54

File tree

4 files changed

+90
-12
lines changed

4 files changed

+90
-12
lines changed

Caddyfile

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
# Handle WebSocket paths without WAF
1212
handle /ws/* {
13-
reverse_proxy localhost:9001 {
13+
reverse_proxy minio:9001 {
1414
header_up Host {http.request.host}
1515
header_up X-Real-IP {remote}
1616
header_up X-Forwarded-For {remote}
@@ -37,7 +37,7 @@
3737
`
3838
}
3939

40-
reverse_proxy localhost:9001 {
40+
reverse_proxy minio:9001 {
4141
header_up Host {http.request.host}
4242
header_up X-Real-IP {remote}
4343
header_up X-Forwarded-For {remote}
@@ -60,6 +60,23 @@
6060
}
6161
}
6262

63+
# --- Keycloak Proxy (port 8082) ---
64+
:8082 {
65+
reverse_proxy keycloak:8080 {
66+
header_up Host localhost:8082
67+
header_up X-Real-IP {remote}
68+
header_up X-Forwarded-Proto http
69+
header_up X-Forwarded-Host localhost:8082
70+
header_up X-Forwarded-Port 8082
71+
}
72+
73+
log {
74+
output stdout
75+
format json
76+
level INFO
77+
}
78+
}
79+
6380
# --- WAF for MinIO API (port 8081) ---
6481
:8081 {
6582
handle /health {
@@ -78,7 +95,7 @@
7895
`
7996
}
8097

81-
reverse_proxy localhost:9000 {
98+
reverse_proxy minio:9000 {
8299
header_up Connection {http.request.header.connection}
83100
header_up Upgrade {http.request.header.upgrade}
84101
}

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Multi-stage build for Coraza-Caddy WAF
22

33
# --- Versions ---
4-
ARG CADDY_VERSION=2.8
4+
ARG CADDY_VERSION=2.9
55
ARG CORAZA_VERSION=v2.0.0
66

77
# --- Build stage ---
@@ -10,7 +10,8 @@ ARG CORAZA_VERSION
1010
ENV CORAZA_VERSION=${CORAZA_VERSION}
1111

1212
RUN xcaddy build \
13-
--with github.com/corazawaf/coraza-caddy@${CORAZA_VERSION}
13+
--with github.com/corazawaf/coraza-caddy@${CORAZA_VERSION} \
14+
--with github.com/caddyserver/replace-response
1415

1516
# --- Runtime stage ---
1617
FROM caddy:${CADDY_VERSION}-alpine

docker-compose.yml

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,90 @@
11
version: '3.8'
2+
23
services:
4+
postgres-db:
5+
image: postgres:16-alpine
6+
container_name: postgres-db
7+
environment:
8+
POSTGRES_DB: ${POSTGRES_DB:-keycloakdb}
9+
POSTGRES_USER: ${POSTGRES_USER:-psuser}
10+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pspassword}
11+
volumes:
12+
- postgres_data:/var/lib/postgresql/data
13+
networks:
14+
- minio-net
15+
16+
keycloak:
17+
image: quay.io/keycloak/keycloak:latest
18+
container_name: keycloak_app
19+
user: root
20+
restart: always
21+
environment:
22+
KC_BOOTSTRAP_ADMIN_USERNAME: ${KEYCLOAK_USER:-admin}
23+
KC_BOOTSTRAP_ADMIN_PASSWORD: ${KEYCLOAK_PASSWORD:-admin}
24+
KC_HTTP_ENABLED: 'true'
25+
KC_HOSTNAME_STRICT: false
26+
KC_PROXY_HEADERS: xforwarded
27+
KEYCLOAK_IMPORT: /opt/keycloak/data/import/realm-config.json
28+
KC_DB: postgres
29+
KC_DB_URL: jdbc:postgresql://postgres-db/${POSTGRES_DB:-keycloakdb}
30+
KC_DB_USERNAME: ${POSTGRES_USER:-psuser}
31+
KC_DB_PASSWORD: ${POSTGRES_PASSWORD:-pspassword}
32+
extra_hosts:
33+
- "host.docker.internal:host-gateway"
34+
volumes:
35+
- ./keycloak-minio-docker/minio-realm-config.json:/opt/keycloak/data/import/minio-realm-config.json
36+
- keycloak-data:/opt/keycloak/data
37+
command: ["start", "--import-realm"]
38+
depends_on:
39+
- postgres-db
40+
networks:
41+
- minio-net
42+
343
minio:
444
image: quay.io/minio/minio:RELEASE.2025-04-22T22-12-26Z
545
container_name: minio
646
command: server /data --console-address ":9001" --address ":9000"
747
environment:
8-
- MINIO_ROOT_USER=minioadmin
9-
- MINIO_ROOT_PASSWORD=your-password
10-
ports:
11-
- "9000:9000"
12-
- "9001:9001"
48+
MINIO_ROOT_USER: minioadmin
49+
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin}
50+
MINIO_IDENTITY_OPENID_CONFIG_URL: http://coraza-waf:8082/realms/minio_realm/.well-known/openid-configuration
51+
MINIO_IDENTITY_OPENID_CLIENT_ID: minio-client
52+
MINIO_IDENTITY_OPENID_CLIENT_SECRET: nrb2E4DKOL7QmShrtTO1O7RERXeKt6UC
53+
MINIO_IDENTITY_OPENID_CLAIM_NAME: "policy"
54+
MINIO_IDENTITY_OPENID_SCOPES: openid,profile,email
55+
MINIO_BROWSER_REDIRECT_URL: http://localhost:8080
56+
MINIO_IDENTITY_OPENID_REDIRECT_URI: http://localhost:8080/oauth_callback
57+
MINIO_IDENTITY_OPENID_DISPLAY_NAME: "Login with SSO"
58+
extra_hosts:
59+
- "host.docker.internal:host-gateway"
60+
- "localhost:172.18.0.1"
1361
volumes:
1462
- minio-data:/data
63+
depends_on:
64+
- keycloak
65+
restart: unless-stopped
1566
networks:
1667
- minio-net
1768

1869
coraza-waf:
1970
image: coraza-waf-local:latest
2071
container_name: coraza-waf
72+
volumes:
73+
- ./Caddyfile:/etc/caddy/Caddyfile
2174
ports:
2275
- "8080:8080"
2376
- "8081:8081"
77+
- "8082:8082"
2478
depends_on:
2579
- minio
80+
- keycloak
2681
networks:
2782
- minio-net
2883

2984
volumes:
3085
minio-data:
86+
postgres_data:
87+
keycloak-data:
3188

3289
networks:
3390
minio-net:

keycloak-minio-docker/minio-realm-config.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@
3434
"directAccessGrantsEnabled": false,
3535
"serviceAccountsEnabled": false,
3636
"standardFlowEnabled": true,
37-
"rootUrl": "http://127.0.0.1:9001",
37+
"rootUrl": "http://localhost:8080",
3838
"redirectUris": [
39-
"http://127.0.0.1:9001/oauth_callback"
39+
"http://localhost:8080/oauth_callback"
40+
],
41+
"webOrigins": [
42+
"http://localhost:8080"
4043
],
4144
"defaultClientScopes": [
4245
"openid",

0 commit comments

Comments
 (0)