Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 69 additions & 13 deletions proxy/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,21 +1,81 @@
events {}
worker_processes auto;

events {
worker_connections 8192;
multi_accept on;
}

http {
# ------------------------------------------------------------------
# Trusted environment (internal Docker network, no untrusted clients):
# everything is deliberately opened up so that large validator sets,
# long REST URLs and long-lived streams are never cut off.
# ------------------------------------------------------------------

# No request body limit (0 = unlimited). Block/attestation publishing
# and bulk validator imports go through here.
client_max_body_size 0;
client_body_buffer_size 1m;

# Request line / header buffers: /eth/v1/beacon/states/head/validators/<ids>
# and multi-pubkey queries easily blow past the 4k/8k defaults.
client_header_buffer_size 32k;
large_client_header_buffers 8 64k;

# Generous timeouts for slow clients, large uploads and idle keepalive.
client_body_timeout 1h;
client_header_timeout 1h;
send_timeout 1h;
keepalive_timeout 1h;
keepalive_requests 100000;
lingering_time 30s;
reset_timedout_connection on;

# Low-latency behaviour for the API.
tcp_nodelay on;
tcp_nopush off;
server_tokens off;

# ------------------------------------------------------------------
# Upstream proxying defaults (applies to every location below).
# ------------------------------------------------------------------
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-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;

proxy_connect_timeout 60s;
proxy_send_timeout 1h;
proxy_read_timeout 1h;
proxy_socket_keepalive on;

# Stream everything: no buffering, so /eth/v1/events SSE stays open and
# large responses start flowing immediately instead of being spooled.
proxy_buffering off;
proxy_request_buffering off;
proxy_max_temp_file_size 0;
proxy_buffer_size 32k;
proxy_buffers 8 64k;
proxy_busy_buffers_size 128k;
chunked_transfer_encoding on;

# Don't abort the upstream request if the client goes away (validator
# clients time out aggressively on block publish).
proxy_ignore_client_abort on;

server {
listen 3500;

location /eth/v1/beacon/states/head/validators/ {
proxy_pass ${BEACON_CHAIN_URL}/eth/v1/beacon/states/head/validators/;
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;
}

location / {
proxy_pass ${VALIDATOR_URL};
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;
}
}

Expand All @@ -24,10 +84,6 @@ http {

location / {
proxy_pass ${BEACON_CHAIN_URL};
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;
}
}
}