2024-11-27 21:00:52 -05:00
|
|
|
js_shared_dict_zone zone=cache:10m;
|
2024-11-10 20:42:02 -05:00
|
|
|
js_import njs/main.js;
|
2024-11-27 21:00:52 -05:00
|
|
|
js_set $cache_dict main.get_cache_dict;
|
2024-11-10 20:42:02 -05:00
|
|
|
|
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
|
default upgrade;
|
|
|
|
|
'' close;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
upstream frontend {
|
2024-12-06 18:19:23 -05:00
|
|
|
server ${FRONTEND_HOST}:${FRONTEND_PORT};
|
2024-11-10 20:42:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
upstream backend {
|
2024-12-06 18:19:23 -05:00
|
|
|
server ${BACKEND_HOST}:${BACKEND_PORT};
|
2024-11-10 20:42:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
2024-12-06 18:19:23 -05:00
|
|
|
listen ${PORT};
|
2024-11-10 22:52:04 -05:00
|
|
|
|
|
|
|
|
set $proxy_target "";
|
2024-12-06 21:01:23 -05:00
|
|
|
|
|
|
|
|
location /health {
|
|
|
|
|
access_log off;
|
|
|
|
|
add_header Content-Type text/plain;
|
|
|
|
|
return 200 'healthy';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /backend-health {
|
|
|
|
|
proxy_pass http://backend/health;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
access_log off;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /frontend-health {
|
|
|
|
|
proxy_pass http://frontend;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
access_log off;
|
|
|
|
|
}
|
2024-11-10 22:52:04 -05:00
|
|
|
|
2024-11-10 20:42:02 -05:00
|
|
|
location /api {
|
|
|
|
|
proxy_pass http://backend;
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Host $host;
|
2024-11-10 22:52:04 -05:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2024-11-10 20:42:02 -05:00
|
|
|
}
|
2024-11-10 22:52:04 -05:00
|
|
|
|
|
|
|
|
# Game WebSocket routing
|
2024-11-15 17:46:01 -05:00
|
|
|
location ~/api/room/([^/]+)/socket {
|
2024-11-10 20:42:02 -05:00
|
|
|
set $room_id $1;
|
2024-11-15 17:46:01 -05:00
|
|
|
js_content main.routeWebSocket;
|
|
|
|
|
}
|
2024-11-10 20:42:02 -05:00
|
|
|
|
2024-11-15 17:46:01 -05:00
|
|
|
# WebSocket proxy location
|
|
|
|
|
location @websocket_proxy {
|
2024-11-10 20:42:02 -05:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
2024-11-15 17:46:01 -05:00
|
|
|
proxy_set_header Connection $connection_upgrade;
|
2024-11-10 20:42:02 -05:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
2024-11-10 22:52:04 -05:00
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2024-11-15 17:46:01 -05:00
|
|
|
|
|
|
|
|
# Timeouts
|
2024-11-10 22:52:04 -05:00
|
|
|
proxy_connect_timeout 7m;
|
|
|
|
|
proxy_send_timeout 7m;
|
|
|
|
|
proxy_read_timeout 7m;
|
2024-11-10 20:42:02 -05:00
|
|
|
proxy_buffering off;
|
2024-11-15 17:46:01 -05:00
|
|
|
|
|
|
|
|
proxy_pass $proxy_target;
|
2024-11-10 20:42:02 -05:00
|
|
|
}
|
2024-11-10 22:52:04 -05:00
|
|
|
|
2024-11-10 20:42:02 -05:00
|
|
|
location / {
|
|
|
|
|
proxy_pass http://frontend;
|
2024-11-10 22:52:04 -05: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;
|
2024-11-10 20:42:02 -05:00
|
|
|
}
|
2024-11-15 19:35:41 -05:00
|
|
|
}
|