Files
TX/docker/nginx.conf
T

57 lines
1.7 KiB
Nginx Configuration File
Raw Normal View History

# Tx OS web — serves the built React/Vite SPA and reverse-proxies the
# API + Socket.IO traffic to the api container on the private network.
upstream tx_api {
server api:8080;
}
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Health endpoint for compose / load balancer probes.
location = /healthz {
access_log off;
return 200 "ok\n";
add_header Content-Type text/plain;
}
# Socket.IO upgrade — must come before the generic /api/ block so the
# WebSocket handshake gets the upgrade headers it needs.
location /api/socket.io/ {
proxy_pass http://tx_api;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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 1h;
}
# All other API calls.
location /api/ {
proxy_pass http://tx_api;
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;
client_max_body_size 25m;
}
# SPA: serve hashed assets with long-cache; fall back to index.html.
location ~* \.(?:js|css|woff2?|png|jpg|jpeg|gif|svg|ico|webp|map)$ {
expires 30d;
add_header Cache-Control "public, immutable";
try_files $uri =404;
}
location / {
try_files $uri $uri/ /index.html;
add_header Cache-Control "no-cache";
}
}