Files
2026-03-17 18:32:44 +03:00

50 lines
1.6 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /api/ {
# Используем переменную и resolver, чтобы nginx не падал при старте,
# если хост 'api' еще не доступен или находится в другой сети Docker.
resolver 127.0.0.11 valid=30s;
set $backend_api api;
proxy_pass http://$backend_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 $http_x_forwarded_proto;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
}
location ~ ^/(docs|redoc|openapi.json) {
resolver 127.0.0.11 valid=30s;
set $backend_api api;
proxy_pass http://$backend_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 $http_x_forwarded_proto;
}
# Кеширование статики
location /assets/ {
root /usr/share/nginx/html;
expires 1y;
add_header Cache-Control "public, no-transform";
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}