# Nginx sidecar to bypass MCP SDK DNS rebinding protection.
#
# The MCP Python SDK's TransportSecurityMiddleware (enabled by default since
# MCP SDK v1.23.0 / CVE-2025-66416) validates the Host header against an
# allowed_hosts list. MindsDB's defaults are ["localhost:*", "127.0.0.1:*"]
# — the wildcard pattern requires "host:PORT" format (bare "localhost" fails).
#
# This proxy rewrites the Host header to localhost:47334 before forwarding
# to MindsDB, matching the "localhost:*" pattern.
#
# See: GitHub Issue #12089 (MindsDB), MCP SDK PR #861, MindsDB PR #12110
server {
listen 47336;
location /mcp/ {
proxy_pass http://mindsdb:47334/mcp/;
proxy_set_header Host localhost:47334;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
# SSE-specific: disable buffering and keep connection alive
proxy_set_header Connection '';
proxy_buffering off;
proxy_cache off;
chunked_transfer_encoding off;
# SSE connections can be long-lived
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}