Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eacc0e86c9 | ||
|
|
ac912cb354 | ||
|
|
e4cee2a06d | ||
|
|
006b405ad5 |
@@ -0,0 +1,10 @@
|
||||
auth.example.test {
|
||||
tls /etc/tls/tls.crt /etc/tls/tls.key
|
||||
|
||||
reverse_proxy keycloak:8080 {
|
||||
header_up Host {host}
|
||||
header_up X-Forwarded-Host {host}
|
||||
header_up X-Forwarded-Port 443
|
||||
header_up X-Forwarded-Proto https
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name auth.example.test;
|
||||
|
||||
ssl_certificate /etc/tls/tls.crt;
|
||||
ssl_certificate_key /etc/tls/tls.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
|
||||
location / {
|
||||
proxy_pass http://keycloak:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-Port 443;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
tunnel: 00000000-0000-0000-0000-000000000000
|
||||
credentials-file: /etc/cloudflared/00000000-0000-0000-0000-000000000000.json
|
||||
|
||||
ingress:
|
||||
- hostname: auth.example.test
|
||||
service: http://reverse-proxy:8080
|
||||
- service: http_status:404
|
||||
@@ -0,0 +1,20 @@
|
||||
# HTTPS termination: nginx or Caddy
|
||||
|
||||
두 예제 모두 public `443`에서 TLS를 종료하고 private Docker network의
|
||||
`keycloak:8080`으로 전달한다. Keycloak 쪽 설정은
|
||||
`deploy/reverse-proxy/keycloak.env.example`의 hostname/proxy contract를
|
||||
같이 사용한다.
|
||||
|
||||
- nginx: 인증서 배포·갱신을 운영자가 담당할 때 적합하다.
|
||||
- Caddy: ACME를 통한 인증서 수명주기를 proxy가 담당하게 할 때 간단하다.
|
||||
- 둘을 동시에 production entry point로 띄우지 않는다.
|
||||
- 인증서와 private key는 repository 또는 image에 포함하지 않는다.
|
||||
- HTTP challenge/redirect 및 방화벽의 80/443 허용은 배포 환경에서 별도로
|
||||
결정한다.
|
||||
|
||||
검증 스크립트는 임시 자체 서명 인증서를 만들고 두 vendor image에서 설정을
|
||||
각각 validate한 뒤 임시 파일을 제거한다.
|
||||
|
||||
```sh
|
||||
./scripts/verify-https-termination-config.sh
|
||||
```
|
||||
@@ -0,0 +1,21 @@
|
||||
# Public HTTPS domain for broker callbacks
|
||||
|
||||
Google brokering을 반복 테스트할 때는 Cloudflare **named tunnel + 관리
|
||||
도메인**을 기본 profile로 사용한다. `trycloudflare.com` quick tunnel과
|
||||
임의 ngrok URL은 일회성 데모용이며 고정 callback으로 간주하지 않는다.
|
||||
|
||||
설정 순서:
|
||||
|
||||
1. `cloudflared tunnel login`
|
||||
2. `cloudflared tunnel create keycloak-patterns`
|
||||
3. 예제 config의 tunnel UUID와 credentials path를 실제 값으로 교체
|
||||
4. `cloudflared tunnel route dns keycloak-patterns auth.example.test`
|
||||
5. `cloudflared tunnel run keycloak-patterns`
|
||||
6. Keycloak `KC_HOSTNAME`과 Google redirect URI를 같은 public host로 설정
|
||||
|
||||
컨테이너 안의 `127.0.0.1`은 cloudflared 컨테이너 자신이므로 origin에는
|
||||
`reverse-proxy:8080` 같은 Compose service DNS를 사용한다. 마지막 catch-all
|
||||
ingress는 알 수 없는 hostname을 404로 끝낸다.
|
||||
|
||||
실 tunnel 생성과 DNS 변경에는 사용자 소유 계정·도메인이 필요하므로 자동
|
||||
검증은 ingress 파일의 구조까지만 수행한다.
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
test_dir="$(mktemp -d)"
|
||||
cleanup() {
|
||||
rm -rf "$test_dir"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
openssl req -x509 -newkey rsa:2048 -nodes -days 1 \
|
||||
-subj "/CN=auth.example.test" \
|
||||
-keyout "$test_dir/tls.key" \
|
||||
-out "$test_dir/tls.crt" >/dev/null 2>&1
|
||||
|
||||
docker run --rm \
|
||||
--add-host keycloak:127.0.0.1 \
|
||||
-v "$PWD/deploy/tls/nginx.conf:/etc/nginx/nginx.conf:ro" \
|
||||
-v "$test_dir:/etc/tls:ro" \
|
||||
nginx:1.29-alpine nginx -t
|
||||
|
||||
docker run --rm \
|
||||
--add-host keycloak:127.0.0.1 \
|
||||
-v "$PWD/deploy/tls/Caddyfile:/etc/caddy/Caddyfile:ro" \
|
||||
-v "$test_dir:/etc/tls:ro" \
|
||||
caddy:2.10.2-alpine caddy validate --config /etc/caddy/Caddyfile
|
||||
|
||||
echo "nginx and Caddy HTTPS termination configurations verified"
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
config=deploy/tunnel/cloudflared-config.yml
|
||||
grep -q '^tunnel: [0-9a-f-]*$' "$config"
|
||||
grep -q '^ - hostname: auth.example.test$' "$config"
|
||||
grep -q '^ service: http://reverse-proxy:8080$' "$config"
|
||||
grep -q '^ - service: http_status:404$' "$config"
|
||||
|
||||
docker run --rm \
|
||||
-v "$PWD/$config:/etc/cloudflared/config.yml:ro" \
|
||||
cloudflare/cloudflared:2025.6.1 \
|
||||
tunnel --config /etc/cloudflared/config.yml ingress validate
|
||||
|
||||
echo "Cloudflare named-tunnel ingress configuration verified"
|
||||
Reference in New Issue
Block a user