2026-07-30 18:06:17 +07:00
|
|
|
events {}
|
|
|
|
|
|
|
|
|
|
http {
|
|
|
|
|
include @NGINX_MIME@;
|
|
|
|
|
|
|
|
|
|
access_log /var/lib/gmw-proxy/nginx-access.log;
|
|
|
|
|
error_log /var/lib/gmw-proxy/nginx-error.log;
|
|
|
|
|
|
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
|
default upgrade;
|
|
|
|
|
'' close;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
# Next.js standalone SSR server (backend-fetching on every render).
|
|
|
|
|
# Not for hand-editing: @NEXT_PORT@ is substituted at build time.
|
|
|
|
|
upstream gmw_next {
|
|
|
|
|
server 127.0.0.1:@NEXT_PORT@;
|
|
|
|
|
keepalive 16;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
upstream gmw_backend {
|
|
|
|
|
server 127.0.0.1:4001;
|
|
|
|
|
keepalive 16;
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-30 18:06:17 +07:00
|
|
|
server {
|
2026-08-02 15:16:16 +07:00
|
|
|
listen 4009;
|
2026-07-30 18:06:17 +07:00
|
|
|
server_name _;
|
|
|
|
|
|
2026-07-31 16:54:41 +07:00
|
|
|
# Use relative redirects (Location: /dashboard/) instead of absolute
|
2026-08-07 10:44:03 +07:00
|
|
|
# URLs that leak the internal listen port (4009) through the reverse proxy.
|
2026-07-31 16:54:41 +07:00
|
|
|
absolute_redirect off;
|
|
|
|
|
|
2026-07-30 18:06:17 +07:00
|
|
|
gzip on;
|
|
|
|
|
gzip_types text/plain text/css application/json application/javascript application/wasm image/svg+xml;
|
|
|
|
|
gzip_min_length 256;
|
|
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
# ── Backend REST ───────────────────────────────────────────────
|
2026-07-30 18:06:17 +07:00
|
|
|
location ^~ /api {
|
2026-08-07 10:44:03 +07:00
|
|
|
proxy_pass http://gmw_backend$uri$is_args$args;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Connection ""; # keepalive to backend
|
2026-07-30 18:06:17 +07:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
# ── Backend WebSocket (realtime shared state + voice PCM) ──────
|
2026-07-30 18:06:17 +07:00
|
|
|
location ^~ /ws {
|
2026-08-07 10:44:03 +07:00
|
|
|
proxy_pass http://gmw_backend$uri$is_args$args;
|
2026-07-30 18:06:17 +07:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
|
proxy_set_header Connection $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_buffering off;
|
|
|
|
|
proxy_read_timeout 86400s;
|
|
|
|
|
proxy_send_timeout 86400s;
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
# ── Next.js build assets — immutable, edge/shareable ───────────
|
|
|
|
|
location ^~ /_next/static/ {
|
|
|
|
|
proxy_pass http://gmw_next$uri$is_args$args;
|
|
|
|
|
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;
|
2026-07-30 18:06:17 +07:00
|
|
|
expires 1y;
|
|
|
|
|
add_header Cache-Control "public, immutable";
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-07 10:44:03 +07:00
|
|
|
# ── Everything else → Next.js server (SSR) ──
|
2026-07-30 18:06:17 +07:00
|
|
|
location / {
|
2026-08-07 10:44:03 +07:00
|
|
|
proxy_pass http://gmw_next$uri$is_args$args;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Connection "";
|
|
|
|
|
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 X-Next-Prefetch $http_x_next_prefetch;
|
|
|
|
|
proxy_buffering off;
|
|
|
|
|
proxy_read_timeout 30s;
|
2026-07-30 18:06:17 +07:00
|
|
|
}
|
|
|
|
|
}
|
2026-08-07 10:44:03 +07:00
|
|
|
}
|