49 lines
1.2 KiB
Plaintext
49 lines
1.2 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
|
|
|
|
proxy_connect_timeout 60s;
|
|
|
|
# Disable buffering for real-time traffic
|
|
proxy_buffering off;
|
|
|
|
set $proxy_read_timeout 60s;
|
|
set $proxy_send_timeout 60s;
|
|
|
|
# If it's a websocket, change timeouts
|
|
if ($is_websocket) {
|
|
set $proxy_read_timeout 3600s;
|
|
set $proxy_send_timeout 3600s;
|
|
}
|
|
|
|
proxy_read_timeout $proxy_read_timeout;
|
|
proxy_send_timeout $proxy_send_timeout;
|
|
}
|
|
}
|
|
|
|
upstream rpc_backend {
|
|
server ${PROXY_HOST}:${RPC_PORT};
|
|
}
|
|
|
|
upstream ws_backend {
|
|
server ${PROXY_HOST}:${WS_PORT};
|
|
} |