diff --git a/notionalapi/proxy/generate_upstream.sh b/notionalapi/proxy/generate_upstream.sh index a8008d35..67527f2c 100644 --- a/notionalapi/proxy/generate_upstream.sh +++ b/notionalapi/proxy/generate_upstream.sh @@ -22,6 +22,11 @@ for service_name in $SERVICES; do server $gw_ip:26657; } + upstream backend_wsrpc_$service_name { + keepalive 16; + server $gw_ip:26658; + } + upstream backend_api_$service_name { keepalive 16; server $gw_ip:1317; diff --git a/notionalapi/proxy/nginx.conf b/notionalapi/proxy/nginx.conf index 98dda312..10671ff4 100644 --- a/notionalapi/proxy/nginx.conf +++ b/notionalapi/proxy/nginx.conf @@ -100,6 +100,19 @@ http { deny all; } + location ~* ^/websocket { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-NginX-Proxy true; + proxy_set_header x-api-key ${xapikey}; + + proxy_pass http://backend_wsrpc_${chain_name}; + } + if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true';