Skip to content

Commit e8aef63

Browse files
committed
gw(deploy): expose inbound_pp_enabled and port_attrs_fetch tunables
Thread the new gateway config knobs through the dstack-app deployment: - .env / .app_env gains `INBOUND_PP_ENABLED` (default false). Set to true only when the gateway runs behind a PP-aware L4 LB; otherwise every connection would be rejected because the parser would try to read a PP header that isn't there. - docker-compose.yaml forwards the new env vars plus the retry/backoff knobs for the background port_attrs fetcher and the pp_header read timeout. - entrypoint.sh writes the corresponding fields into gateway.toml, including the new [core.proxy.port_attrs_fetch] section. Defaults match the in-repo gateway.toml so existing deployments continue to work without any .env changes.
1 parent 68f4f68 commit e8aef63

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

gateway/dstack-app/builder/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ localhost_enabled = false
111111
app_address_ns_compat = true
112112
workers = ${PROXY_WORKERS:-32}
113113
max_connections_per_app = ${MAX_CONNECTIONS_PER_APP:-0}
114+
inbound_pp_enabled = ${INBOUND_PP_ENABLED:-false}
114115
115116
[core.proxy.timeouts]
116117
connect = "${TIMEOUT_CONNECT:-5s}"
@@ -122,6 +123,13 @@ idle = "${TIMEOUT_IDLE:-10m}"
122123
write = "${TIMEOUT_WRITE:-5s}"
123124
shutdown = "${TIMEOUT_SHUTDOWN:-5s}"
124125
total = "${TIMEOUT_TOTAL:-5h}"
126+
pp_header = "${TIMEOUT_PP_HEADER:-5s}"
127+
128+
[core.proxy.port_attrs_fetch]
129+
timeout = "${PORT_ATTRS_FETCH_TIMEOUT:-10s}"
130+
max_retries = ${PORT_ATTRS_FETCH_MAX_RETRIES:-5}
131+
backoff_initial = "${PORT_ATTRS_FETCH_BACKOFF_INITIAL:-1s}"
132+
backoff_max = "${PORT_ATTRS_FETCH_BACKOFF_MAX:-30s}"
125133
126134
[core.recycle]
127135
enabled = true

gateway/dstack-app/deploy-to-vmm.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ WG_ADDR=0.0.0.0:9202
9494
# The token used to launch the App
9595
APP_LAUNCH_TOKEN=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
9696
97+
# PROXY protocol: read v1/v2 header from inbound connections (e.g. when this
98+
# gateway sits behind a PP-aware L4 LB such as Cloudflare Spectrum or haproxy
99+
# with send-proxy). Set to "true" only if the upstream LB is configured to
100+
# send PROXY headers; otherwise leave disabled or every connection will be
101+
# rejected.
102+
# INBOUND_PP_ENABLED=false
103+
97104
EOF
98105
echo "Please edit the .env file and set the required variables, then run this script again."
99106
exit 1
@@ -175,6 +182,7 @@ APP_LAUNCH_TOKEN=$APP_LAUNCH_TOKEN
175182
RPC_DOMAIN=$RPC_DOMAIN
176183
NODE_ID=$NODE_ID
177184
PROXY_LISTEN_PORT=$PROXY_LISTEN_PORT
185+
INBOUND_PP_ENABLED=${INBOUND_PP_ENABLED:-false}
178186
EOF
179187

180188
if [ -n "$APP_COMPOSE_FILE" ]; then

gateway/dstack-app/docker-compose.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ services:
4141
- TIMEOUT_TOTAL=${TIMEOUT_TOTAL:-5h}
4242
- ADMIN_LISTEN_ADDR=${ADMIN_LISTEN_ADDR:-0.0.0.0}
4343
- ADMIN_LISTEN_PORT=${ADMIN_LISTEN_PORT:-8001}
44+
- INBOUND_PP_ENABLED=${INBOUND_PP_ENABLED:-false}
45+
- TIMEOUT_PP_HEADER=${TIMEOUT_PP_HEADER:-5s}
46+
- PORT_ATTRS_FETCH_TIMEOUT=${PORT_ATTRS_FETCH_TIMEOUT:-10s}
47+
- PORT_ATTRS_FETCH_MAX_RETRIES=${PORT_ATTRS_FETCH_MAX_RETRIES:-5}
48+
- PORT_ATTRS_FETCH_BACKOFF_INITIAL=${PORT_ATTRS_FETCH_BACKOFF_INITIAL:-1s}
49+
- PORT_ATTRS_FETCH_BACKOFF_MAX=${PORT_ATTRS_FETCH_BACKOFF_MAX:-30s}
4450
restart: always
4551

4652
volumes:

0 commit comments

Comments
 (0)