o2o-triple-pick/frontend/nginx.conf
jwkim 3a5fc36ee8 플레이어에 가사 보기·공유하기 + 응원가 전용 OG 공유 카드
- 하단 MusicBar: 가사 패널 토글(바 위로 펼침)·공유 버튼(네이티브 공유,
  폴백 클립보드) — 응원가 트랙에만 노출
- 공유 링크 /song/:matchId/:teamCode — 크롤러(카톡·페북)는 "오늘의 OO
  응원가" 제목 + Suno 앨범아트 OG 카드, 사람은 경기 페이지로 리다이렉트
  후 그 팀 응원가 자동 로드(?song=)
- nginx /song/ 크롤러 분기 추가

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-25 10:20:54 +09:00

51 lines
2.0 KiB
Nginx Configuration File

# 공유 크롤러(카카오톡·트위터·페북 등) 판별 → /match/:id 만 백엔드 OG 프리렌더로.
# 일반 사용자(JS 실행)는 0 → 기존 SPA 그대로.
map $http_user_agent $is_share_crawler {
default 0;
# kakaotalk-scrap = 카톡 공유 미리보기 봇만. (인앱 브라우저 UA 'KAKAOTALK x.x'
# 는 안 걸려야 사용자가 링크를 탭했을 때 SPA 로 정상 진입한다)
"~*(kakaotalk-scrap|facebookexternalhit|facebot|twitterbot|slackbot|discordbot|telegrambot|whatsapp|line\\b|skypeuripreview|pinterest|redditbot|googlebot|bingbot|daumoa|yeti)" 1;
}
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# API 는 백엔드(api 서비스)로 프록시 → 브라우저는 동일 출처로 호출(CORS 불필요).
location /api/ {
proxy_pass http://api:8000;
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;
}
# 경기 공유 링크: 크롤러면 백엔드 OG 프리렌더, 사람이면 SPA.
# (418 → 내부 named location 으로 우회: if + try_files 충돌 회피 정석 패턴)
location /match/ {
error_page 418 = @og_prerender;
if ($is_share_crawler) { return 418; }
try_files $uri /index.html;
}
# 응원가 공유 링크(/song/:matchId/:teamCode) — 동일 패턴
location /song/ {
error_page 418 = @og_prerender;
if ($is_share_crawler) { return 418; }
try_files $uri /index.html;
}
location @og_prerender {
proxy_pass http://api:8000;
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;
}
# SPA 폴백 — 클라이언트 라우팅(/match/:id 등)
location / {
try_files $uri $uri/ /index.html;
}
}