82 lines
3.1 KiB
Nginx Configuration File
82 lines
3.1 KiB
Nginx Configuration File
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;
|
||
}
|
||
|
||
# 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;
|
||
}
|
||
}
|