Files
o2o-weather/frontend/nginx.conf
T
skkim dc8201e5f5 feat: 다른 사이트에 붙이는 날씨각 위젯 — 누구나 붙이는 카드(/embed/card, 기본형·상세형, 배경 3종)와 사용 방법 페이지(/widget, 스크립트·iframe 코드)
- 카드: 군산각 카드를 옮겨 그림, 토끼 로딩, 실패하면 '날씨각에서 날씨 보기' 링크, 8초 제한, nginx 대체 화면, '자세히 보기' 버튼만 링크
- 크기: 폭은 자리에 맞춰 자동, 높이는 폭에 따라 비율대로(기본형 245~320px, 상세형 400~520px)
- 부하: 지역별 카드 데이터 5분 저장, 저장분이 비면 지역마다 한 요청만 새로 만듦, 노출 수는 Redis 에 쌓았다가 관리자 조회 때 DB(widget_view_daily)로 옮김
- 사용 방법 페이지: 지역(앱 지역은 바꾸지 않음)·모양·배경 고르기, 미리보기, 코드 복사. 들어오는 길은 문의 창 버튼(토스에서는 숨김)과 검색
- GA: 위젯_안내_보기, 위젯_옵션_고름, 위젯_코드_복사
- 문서: docs/위젯_운영.md, 백엔드 테스트 실행법(CLAUDE.md)
2026-11-26 13:03:29 +09:00

106 lines
4.2 KiB
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# 폴더 주소로 넘길 때 포트가 빠지지 않게 상대 주소로 보낸다
absolute_redirect off;
# 앞단 프록시(사설망)가 붙인 X-Forwarded-For 에서 실제 접속 주소를 꺼내 $remote_addr 로 쓴다 (비로그인 좋아요를 IP 로 세려고)
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 192.168.0.0/16;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
gzip on;
gzip_types text/css application/javascript image/svg+xml application/json;
# 해시가 붙은 빌드 파일은 오래 캐시
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
try_files $uri =404;
}
location /icons/ {
add_header Cache-Control "public, max-age=604800";
try_files $uri =404;
}
location /b/icons/ {
add_header Cache-Control "public, max-age=604800";
try_files $uri =404;
}
# 인스타 올리기는 백엔드가 인스타 쪽 처리(캐러셀 컨테이너·영상 변환)를 기다리느라 1분을 넘길 수 있다 (기본 60s 면 504)
location ~ ^/v1/(card|reel)/[0-9]+/instagram$ {
resolver 127.0.0.11 valid=10s ipv6=off;
set $api http://backend:9800;
proxy_pass $api;
proxy_read_timeout 600s;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 다른 사이트에 붙이는 날씨 카드: 백엔드가 HTML 을 만든다 (Referer 는 노출 집계에 쓴다)
# 백엔드가 죽었거나(502) 10초 안에 답하지 않으면(504) 오류 화면 대신 조용한 화면(quiet.html, 200)을 준다.
# 404(잘못된 입력)는 백엔드가 만든 조용한 화면 그대로 둔다. 백엔드는 카드 만들기를 8초에 끊는다(CARD_BUILD_TIMEOUT_SEC)
location = /embed/card {
resolver 127.0.0.11 valid=10s ipv6=off;
set $api http://backend:9800;
proxy_pass $api/v1/embed/card$is_args$args;
proxy_set_header Host $http_host;
proxy_connect_timeout 3s;
proxy_read_timeout 10s;
proxy_intercept_errors on;
error_page 500 502 503 504 = @embed_quiet;
}
location @embed_quiet {
add_header Cache-Control "no-store";
try_files /embed/quiet.html =404;
}
# 카드가 쓰는 정적 파일. 이름에 해시가 없어 짧게 캐시하고, 고치면 주소의 ?v= 를 올린다
location /embed/ {
add_header Cache-Control "public, max-age=3600";
try_files $uri =404;
}
# API 는 같은 주소로 받아 backend 컨테이너로 넘긴다
location /v1/ {
# 카드뉴스 올리기(/v1/card)는 1080×1350 JPEG 최대 20장을 base64 로 한 번에 보낸다 (기본 1m 로는 413)
client_max_body_size 40m;
# 백엔드 컨테이너가 다시 뜨면 IP 가 바뀌므로 docker DNS 로 매번 다시 찾는다
resolver 127.0.0.11 valid=10s ipv6=off;
set $api http://backend:9800;
proxy_pass $api;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 지역 검색 페이지: 백엔드가 정적 HTML(today·tomorrow/…/….html)에 오늘·내일 날씨를 채워 준다. 백엔드가 안 되면 정적 HTML 그대로
location ~ ^/(today|tomorrow)/[a-z]+/[a-z]+(/[a-z]+)?$ {
resolver 127.0.0.11 valid=10s ipv6=off;
set $api http://backend:9800;
proxy_pass $api/v1/seo$uri;
proxy_set_header Host $host;
proxy_connect_timeout 3s;
proxy_read_timeout 20s;
proxy_intercept_errors on;
error_page 404 500 502 503 504 = @static;
}
location @static {
add_header Cache-Control "no-store";
try_files $uri.html /index.html;
}
# HTML 은 no-store: no-cache 면 다시 연 탭·뒤로 가기에서 예전 HTML 을 다시 써서, 배포로 지워진 빌드 파일을 부르다 멈춘다
# SPA: /gak 처럼 빌드 때 만든 페이지별 HTML(gak.html)이 있으면 그것을, 없으면 index.html. 폴더는 안 찾는다 (/season 이 이미지 폴더 public/season 과 겹쳐 403)
location / {
add_header Cache-Control "no-store";
try_files $uri $uri.html /index.html;
}
}