iac/nginx/nginx.conf

82 lines
2.5 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.

worker_processes auto;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
large_client_header_buffers 8 128k;
client_max_body_size 5000M; # крупные загрузки (снимки, облака точек)
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# корректная поддержка websocket/keep-alive для upstream'ов
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream backend { server backend:8000; }
upstream frontend { server frontend:80; }
upstream minio_s3 { server minio:9000; }
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 $scheme;
server {
listen 80;
listen [::]:80;
# healthcheck самого nginx
location = /healthz {
access_log off;
add_header Content-Type text/plain;
return 200 "ok\n";
}
# --- Django backend: REST API + админка ---
location /api/ {
proxy_pass http://backend;
}
location /admin/ {
proxy_pass http://backend;
}
# --- MinIO: объекты бакета ---
# Путь НЕ переписываем — иначе ломается подпись SigV4. Чтобы медиа
# открывались из браузера, задай backend'у S3_HOST = http://<хост>:9080
# (сейчас в compose там http://minio:9000, внутренний адрес).
location /sarex-media-storage/ {
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://minio_s3;
}
# --- Frontend SPA (host-приложение само отдаёт статику и роутинг) ---
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://frontend;
}
}
}