Skip to content
Merged
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ COPY --from=builder /usr/local/go/src/github.com/6022-labs/agentic-agent-node/sr
COPY --from=web-builder /web/dist /web
COPY nginx.conf /etc/nginx/http.d/default.conf

# Client IP for the rate limiter: trust nginx and private-network edges; keep 127.0.0.1 when overriding.
# Client IP for the rate limiter: nginx resolves it from the edge in front, trusting loopback, private and shared ranges.
ENV PROXY__HEADER=X-Forwarded-For \
PROXY__TRUSTED_PROXIES=127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7
PROXY__TRUSTED_PROXIES=127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,fc00::/7

# Pre-filled defaults that hold whenever the three processes share a container:
# both Go hosts bind the loopback interface (only nginx is reachable from
Expand Down Expand Up @@ -111,9 +111,20 @@ RUNTIME_PID=$!
# the gateway starts dialling /internal/* on it.
sleep 1

gateway &
# The gateway only sees nginx, so it reads the client IP nginx resolved from PROXY__*.
PROXY__HEADER=X-Real-IP PROXY__TRUSTED_PROXIES=127.0.0.1 gateway &
GATEWAY_PID=$!

REAL_IP_CONF=/etc/nginx/http.d/real_ip.conf
rm -f "$REAL_IP_CONF"
if [ -n "${PROXY__HEADER:-}" ]; then
for PROXY in $(echo "${PROXY__TRUSTED_PROXIES:-}" | tr ',' ' '); do
echo "set_real_ip_from $PROXY;" >> "$REAL_IP_CONF"
done
echo "real_ip_header $PROXY__HEADER;" >> "$REAL_IP_CONF"
echo "real_ip_recursive on;" >> "$REAL_IP_CONF"
fi

nginx -g 'daemon off;' &
NGINX_PID=$!

Expand Down
4 changes: 2 additions & 2 deletions src/gateway_host/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ GATEWAY_HOST__API_PORT=5000
GATEWAY_HOST__BODY_LIMIT_BYTES=4194304 # Default: 4194304 (4MB)

RATE_LIMIT__REQUESTS_PER_SECOND=50 # Default: 50, per client IP
PROXY__HEADER= # optional, e.g. X-Forwarded-For; honored only from PROXY__TRUSTED_PROXIES
PROXY__TRUSTED_PROXIES= # optional, comma-separated IPs or CIDR ranges; the Docker image trusts 127.0.0.1 + private ranges, keep 127.0.0.1 when overriding
PROXY__HEADER= # optional, e.g. X-Forwarded-For, or X-Real-IP when the edge adds its own hop to X-Forwarded-For; honored only from PROXY__TRUSTED_PROXIES
PROXY__TRUSTED_PROXIES= # optional, comma-separated IPs or CIDR ranges; the Docker image trusts 127.0.0.1 + private and shared (100.64.0.0/10) ranges, keep 127.0.0.1 when overriding

TELEMETRY__ENABLED=false
# grpc (default) or http; endpoint stays host:port (collector 4317 for grpc, 4318 for http).
Expand Down
4 changes: 2 additions & 2 deletions src/gateway_host/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ FROM scratch AS final
COPY --from=builder /app /app
COPY --from=builder /etc/ssl/certs /etc/ssl/certs

# Client IP for the rate limiter: trust loopback and private-network edges; keep 127.0.0.1 when overriding.
# Client IP for the rate limiter: trust loopback, private and shared-range edges; keep 127.0.0.1 when overriding.
ENV PROXY__HEADER=X-Forwarded-For \
PROXY__TRUSTED_PROXIES=127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fc00::/7
PROXY__TRUSTED_PROXIES=127.0.0.1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.64.0.0/10,fc00::/7

EXPOSE 5000

Expand Down