food-market/deploy/nginx.conf
nns 2ea30bb30a
Some checks are pending
CI / Backend (.NET 8) (push) Waiting to run
CI / Web (React + Vite) (push) Waiting to run
CI / POS (WPF, Windows) (push) Waiting to run
Docker Web / Build + push Web (push) Waiting to run
Docker Web / Deploy Web on stage (push) Blocked by required conditions
deploy(nginx): /hubs/ → API с upgrade-хедерами для WebSocket
SignalR-клиент на стейдже падал на негоциации — nginx без upgrade-хедеров
не пропускал WebSocket-handshake (POST /hubs/notifications/negotiate → 405).

Добавлен location /hubs/ с proxy_set_header Upgrade/Connection и
proxy_read/send_timeout=24h, иначе nginx рвал бы idle-соединения каждые 60с.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-31 19:38:04 +05:00

74 lines
2.7 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.

server {
listen 80 default_server;
root /usr/share/nginx/html;
index index.html;
# Long-running admin imports (MoySklad etc.) read from upstream for tens of
# minutes. Bump timeouts only on that path so normal API stays snappy.
location /api/admin/import/ {
proxy_pass http://api:8080;
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 X-Forwarded-Proto $scheme;
proxy_read_timeout 60m;
proxy_send_timeout 60m;
proxy_request_buffering off;
proxy_buffering off;
}
# API reverse-proxy — upstream name "api" resolves in the compose network.
location /api/ {
proxy_pass http://api:8080;
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 X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /connect/ {
proxy_pass http://api:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# SignalR хаб для live-уведомлений (см. NotificationsHub).
# WebSocket требует upgrade-хедеры и большой read_timeout (иначе nginx
# будет рвать idle-коннекшен каждые 60 сек). access_token приходит как
# query (?access_token=...), Authorization-хедер middleware на API его
# перекладывает в нужный вид до UseAuthentication.
location /hubs/ {
proxy_pass http://api:8080;
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 X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400; # 24h — webSocket долгоживущий
proxy_send_timeout 86400;
proxy_buffering off;
}
location /health {
proxy_pass http://api:8080;
}
# Статика изображений товаров — api раздаёт /uploads/... из volume.
location /uploads/ {
proxy_pass http://api:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
}
# SPA fallback — all other routes return index.html
location / {
try_files $uri $uri/ /index.html;
}
}