Skip to content

Commit

Permalink
feat: nginx robots.txt, sitemap.xml 정적파일 호스팅
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovico7 committed Dec 2, 2024
1 parent 87f6d9c commit 6029101
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ server {
# HSTS 설정 (HTTPS 강제)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

location = /robots.txt {
root /usr/share/nginx/html; # React 빌드 결과물이 있는 디렉토리
access_log off;
add_header Cache-Control "public, max-age=86400"; # 24시간 캐싱
}

location = /sitemap.xml {
root /usr/share/nginx/html;
access_log off;
add_header Cache-Control "public, max-age=86400";
}

# /api 경로로 들어오는 요청은 백엔드로 전달
location /api {
proxy_pass http://backend; # 백엔드로 요청 전달
Expand Down
10 changes: 10 additions & 0 deletions nginx/default.dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ upstream frontend {
server {
listen 80;

location = /robots.txt {
proxy_pass http://frontend; # 개발 서버로 전달
access_log off;
}

location = /sitemap.xml {
proxy_pass http://frontend;
access_log off;
}

# /api 경로로 들어오는 요청은 백엔드로 전달
location /api {
proxy_pass http://backend; # 백엔드로 요청 전달
Expand Down

0 comments on commit 6029101

Please sign in to comment.