security: 웹루트 분리 — COPY . → COPY public/ + nginx deny 3중 방어
3개 서비스(system1/system2/system3 web)에서 Dockerfile, nginx.conf, docker-compose.yml이 외부 노출되는 취약점 수정. [구조 수정] - Dockerfile: COPY . → COPY public/ (정적 파일만 웹루트에 복사) - system3 uploads: plain prefix → ^~ (regex deny 우선순위 충돌 방지) [nginx deny (defense in depth)] - exact match: /Dockerfile, /docker-compose.yml, /nginx.conf, /.env, /.gitignore - prefix: ^~ /.git/ 디렉토리 전체 차단 - regex: 하위 경로 + 변형 대비 [CI 보안 게이트] - scripts/check-webroot-security.sh: 화이트리스트 방식, find + exact match Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
FROM nginx:alpine
|
||||
|
||||
COPY . /usr/share/nginx/html/
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY public/ /usr/share/nginx/html/
|
||||
EXPOSE 80
|
||||
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
|
||||
@@ -13,6 +13,22 @@ server {
|
||||
# 사진 업로드를 위한 body 크기 제한 (base64 인코딩 시 원본 대비 ~33% 증가)
|
||||
client_max_body_size 50m;
|
||||
|
||||
# 민감 파일 차단 — exact match (^~ 우회 불가)
|
||||
location = /Dockerfile { return 404; }
|
||||
location = /docker-compose.yml { return 404; }
|
||||
location = /nginx.conf { return 404; }
|
||||
location = /.env { return 404; }
|
||||
location = /.gitignore { return 404; }
|
||||
|
||||
# .git 디렉토리 전체 차단
|
||||
location ^~ /.git/ { return 404; }
|
||||
location = /.git { return 404; }
|
||||
|
||||
# 민감 파일 차단 — regex (하위 경로 + 변형 대비)
|
||||
location ~* (Dockerfile|docker-compose|\.env|nginx\.conf) {
|
||||
return 404;
|
||||
}
|
||||
|
||||
# 정적 파일 캐시
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
|
||||
expires 1h;
|
||||
|
||||
Reference in New Issue
Block a user