300926
This commit is contained in:
1 parent
78ba250c37
commit
3f01dd28c6
36 files changed
+3801
-62
No files matched your search
@@ -0,0 +1,54 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
gzip on;
|
||||
gzip_types text/css application/javascript application/json image/svg+xml;
|
||||
gzip_min_length 1024;
|
||||
|
||||
# SPA-роутинг: всего, чего нет файлом, отдаём index.html
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# индекс не кэшируем — иначе после деплоя браузер держит старый бандл
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-cache";
|
||||
}
|
||||
|
||||
# хэшированные ассеты можно надолго
|
||||
location /assets/ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# API бэкенда (сервис `backend` в той же сети compose): путь передаём целиком
|
||||
# через $request_uri, поэтому /api, /api/positions, /api/prices/stream — как есть.
|
||||
#
|
||||
# upstream в переменную + resolver = nginx НЕ резолвит имя при старте. Иначе
|
||||
# `nginx -t` и сам контейнер падают с "host not found in upstream", если
|
||||
# backend ещё не поднялся (а с переменной URI не вырезается, поэтому
|
||||
# $request_uri передаём явно).
|
||||
location /api {
|
||||
resolver 127.0.0.11 valid=10s ipv6=off;
|
||||
set $api_upstream http://backend:8000;
|
||||
proxy_pass $api_upstream$request_uri;
|
||||
proxy_http_version 1.1;
|
||||
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 Connection "";
|
||||
|
||||
# SSE (/api/prices/stream): по умолчанию nginx буферизует ответ, и «живая
|
||||
# цена» молчала бы пачками. Отключаем буферизацию и длинные таймауты.
|
||||
proxy_buffering off;
|
||||
proxy_cache off;
|
||||
chunked_transfer_encoding on;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
add_header X-Accel-Buffering no;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user