-
Notifications
You must be signed in to change notification settings - Fork 198
Strip endpointPrefix from request paths in transparent proxy #3372
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workinggoPull requests that update go codePull requests that update go codeproxy
Description
Problem
The transparent proxy currently rewrites SSE endpoint URLs in responses to include the configured endpointPrefix, but it doesn't strip the prefix from incoming request paths before forwarding to the backend MCP server.
This causes issues in two scenarios:
-
Direct client access: When a client makes a request directly to the proxy with the prefix (e.g.,
/playwright/sse), the proxy forwards it as-is to the backend, which expects/ssewithout the prefix. -
Ingress without prefix stripping: When an ingress controller doesn't strip the prefix before forwarding, the backend receives requests with the prefix that it doesn't expect.
Current Behavior
- SSE response URLs are rewritten with prefix:
/sse→/playwright/sse✓ - Request paths are forwarded as-is:
/playwright/sse→ backend receives/playwright/sse✗
Expected Behavior
- If ingress already stripped the prefix (detected via
X-Forwarded-Prefixheader), proxy should not strip again - If ingress didn't strip OR client makes direct request, proxy should strip the prefix before forwarding
- Backend should always receive paths without the prefix:
/playwright/sse→/sse
Solution
Implement prefix stripping in the proxy's Director function that:
- Strips
endpointPrefixfrom request paths when present at the start - Detects if ingress already stripped via
X-Forwarded-Prefixheader (whentrustProxyHeadersis enabled) - Handles edge cases like prefix appearing later in path (e.g.,
/abc/abc/ssewith prefix/abc→/abc/sse)
Related
- Affects: SSE transport with
endpointPrefixconfiguration - Related to: Ingress path-based routing scenarios
- Implementation:
pkg/transport/proxy/transparent/transparent_proxy.go
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggoPull requests that update go codePull requests that update go codeproxy