41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
map $http_upgrade $proxy_connection {
|
|
default "rpc_backend${RPC_PATH}";
|
|
websocket "ws_backend${WS_PATH}";
|
|
}
|
|
|
|
map $http_upgrade $is_websocket {
|
|
default 0;
|
|
websocket 1;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
location / {
|
|
proxy_pass http://$proxy_connection;
|
|
proxy_set_header Host localhost;
|
|
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; # Forward Upgrade header
|
|
proxy_set_header Connection $http_connection; # Forward Connection header
|
|
|
|
# Ensure the connection stays open indefinitely on websockets
|
|
proxy_read_timeout $is_websocket ? 3600s : 60s;
|
|
proxy_send_timeout $is_websocket ? 3600s : 60s;
|
|
|
|
proxy_connect_timeout 60s;
|
|
|
|
# Disable buffering for real-time traffic
|
|
proxy_buffering off;
|
|
}
|
|
}
|
|
|
|
upstream rpc_backend {
|
|
server ${PROXY_HOST}:${RPC_PORT};
|
|
}
|
|
|
|
upstream ws_backend {
|
|
server ${PROXY_HOST}:${WS_PORT};
|
|
} |