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>
109 lines
3.3 KiB
Nginx Configuration File
109 lines
3.3 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name _;
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
|
|
client_max_body_size 10M;
|
|
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
root /usr/share/nginx/html;
|
|
index issues-dashboard.html;
|
|
|
|
# 민감 파일 차단 — 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;
|
|
}
|
|
|
|
# gzip 압축
|
|
gzip on;
|
|
gzip_types text/plain text/css application/javascript application/json;
|
|
gzip_min_length 1024;
|
|
|
|
# HTML 캐시 비활성화
|
|
location ~* \.html$ {
|
|
expires -1;
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
|
}
|
|
|
|
# JS/CSS 캐시 활성화 (버전 쿼리 스트링으로 무효화)
|
|
location ~* \.(js|css)$ {
|
|
expires 1h;
|
|
add_header Cache-Control "public, no-transform";
|
|
}
|
|
|
|
# 정적 파일 (이미지 등)
|
|
location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf)$ {
|
|
expires 1h;
|
|
add_header Cache-Control "public, no-transform";
|
|
}
|
|
|
|
# API 프록시 (System 3 API)
|
|
location /api/ {
|
|
set $upstream http://system3-api:8000;
|
|
proxy_pass $upstream$request_uri;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
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_cache_bypass $http_upgrade;
|
|
|
|
# 엑셀 생성 등 시간이 걸리는 API 대응
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
proxy_buffering off;
|
|
}
|
|
|
|
# AI API 프록시 (맥미니 home-service-proxy 경유)
|
|
location /ai-api/ {
|
|
set $ai_upstream https://ai.hyungi.net;
|
|
rewrite ^/ai-api/(.*) /api/ai/$1 break;
|
|
proxy_pass $ai_upstream;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host ai.hyungi.net;
|
|
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_ssl_server_name on;
|
|
proxy_read_timeout 180s;
|
|
proxy_send_timeout 180s;
|
|
}
|
|
|
|
# 모바일 전용 페이지
|
|
location /m/ {
|
|
alias /usr/share/nginx/html/m/;
|
|
try_files $uri $uri/ /m/dashboard.html;
|
|
location ~* \.html$ {
|
|
expires -1;
|
|
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
|
}
|
|
}
|
|
|
|
# 업로드 파일 (^~ 로 regex deny보다 우선 매칭)
|
|
location ^~ /uploads/ {
|
|
alias /usr/share/nginx/html/uploads/;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
location / {
|
|
try_files $uri $uri/ /issues-dashboard.html;
|
|
}
|
|
}
|