feat(infra): HTTPS(TLS) 스캐폴딩 + 프록시 헤더 처리
- Spring prod: server.forward-headers-strategy=framework — nginx의 X-Forwarded-Proto를 신뢰해 프록시 뒤에서도 request.isSecure()=true → Secure 쿠키·https 리다이렉트 정상화. - frontend/nginx-tls.conf: 443 TLS 종료 + 80→443 리다이렉트(+ /api 프록시). - infra/docker-compose.tls.yml: base와 함께 쓰는 HTTPS 오버레이(443 매핑·인증서 볼륨· ACS_PUBLIC_BASE_URL/ACS_COOKIE_SECURE). infra/certs/.gitignore로 인증서·키 커밋 제외. - README: HTTPS 적용 절차(인증서 준비→.env→compose 오버레이) 갱신. 검증: forward-headers=framework + cookie.secure=true로 기동 후 X-Forwarded-Proto=https 유무 대조 — 헤더 있으면 XSRF-TOKEN·JSESSIONID 모두 Secure, 없으면 XSRF Secure 미부여(프록시 프로토콜 연동 확인). 자체서명 인증서 생성 확인. 전체 컨테이너 TLS e2e는 Docker 데몬 기동 시 별도 검증 필요. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
43
frontend/nginx-tls.conf
Normal file
43
frontend/nginx-tls.conf
Normal file
@@ -0,0 +1,43 @@
|
||||
# HTTPS variant of nginx.conf — used by the docker-compose.tls.yml overlay.
|
||||
# nginx terminates TLS and reverse-proxies /api to the backend over the internal network.
|
||||
# Mount a certificate at /etc/nginx/certs/{fullchain.pem,privkey.pem}.
|
||||
|
||||
# Redirect all plain HTTP to HTTPS.
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
http2 on;
|
||||
server_name _;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/privkey.pem;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# SPA client-side routing: fall back to index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Proxy API calls to the backend service (session cookie preserved).
|
||||
# X-Forwarded-Proto=https lets the app (server.forward-headers-strategy=framework)
|
||||
# know the original request was secure → Secure cookies + https redirects.
|
||||
location /api/ {
|
||||
proxy_pass http://app:8080;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cookie_path / /;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user