aspans_patrol/docker/nginx.conf
2026-10-22 10:53:02 +05:00

48 lines
1.9 KiB
Nginx Configuration File
Raw Permalink 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;
# Куски видео по 8 МБ + запас
client_max_body_size 16m;
# Адреса api и tiles спрашиваем у DNS Docker на каждый запрос (кэш 10 с), а не один раз при старте:
# иначе после пересоздания контейнера (новый IP) nginx ходит по старому адресу и отдаёт 502.
# Для этого адрес — в переменной: с переменной nginx резолвит имя в рантайме через resolver.
resolver 127.0.0.11 valid=10s ipv6=off;
set $api_upstream http://api:3000;
set $tiles_upstream http://tiles:8080;
location /api/ {
proxy_pass $api_upstream;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 120s;
# видео отдаём потоком, не буферизуем целиком
proxy_buffering off;
}
location /tiles/ {
# с переменной в proxy_pass префикс сам не срезается — срезаем /tiles/ явно
rewrite ^/tiles/(.*)$ /$1 break;
proxy_pass $tiles_upstream;
proxy_set_header Host $host;
expires 7d;
}
# service worker и манифест не кэшируем, иначе обновление приложения не доедет до телефонов
location = /sw.js { add_header Cache-Control "no-cache"; try_files $uri =404; }
location = /manifest.webmanifest { add_header Cache-Control "no-cache"; try_files $uri =404; }
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
location / {
try_files $uri $uri/ /index.html;
}
}