Skip to content

Fix platform-http-proxy example: reverse proxy instead of self-referential CamelHttpUrl - #207

Open
Croway wants to merge 2 commits into
apache:mainfrom
Croway:fix-platform-http-proxy
Open

Fix platform-http-proxy example: reverse proxy instead of self-referential CamelHttpUrl#207
Croway wants to merge 2 commits into
apache:mainfrom
Croway:fix-platform-http-proxy

Conversation

@Croway

@Croway Croway commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

The platform-http-proxy example was broken in three ways:

  • The README's curl --proxy command never reached the route: servlet containers normalize an absolute-form request line down to just the path, discarding the target host, so the request never matched platform-http:proxy/*.
  • toD("${headers.CamelHttpUrl}") used the incoming request's own URL (CamelHttpUrl is set from request.getRequestURL(), i.e. this application's own address), causing the route to call itself in an infinite loop until the HTTP connection pool exhausted (503s).
  • The consumer path literal proxy collides with a reserved marker in camel-platform-http that turns the endpoint into a catch-all consumer for a Host-header-based forward proxy - a mode only implemented by the Vert.x platform-http engine, not by camel-platform-http-starter (the servlet/Spring MVC engine this example uses). Left as-is it silently degrades into an unguarded catch-all matching unrelated paths instead of 404ing.

Redesigned as a real path-based reverse proxy: requests under /reverse-proxy/** are forwarded to a configurable backend (reverse-proxy.target-base-uri) using camel-http's bridgeEndpoint mode, which appends CamelHttpPath/CamelHttpQuery onto the fixed target automatically instead of trusting a self-referential header.

Test plan

  • mvn compile on the module
  • Ran the app locally and hit it with curl against real httpbin.org:
    • GET /reverse-proxy/get?arg1=val1 forwards to httpbin.org/get, query string preserved
    • GET /reverse-proxy and /reverse-proxy/ forward correctly to the backend root
    • Unrelated paths (/nope, /xyz, /reverse-proxyfoo, /other/path) correctly return 404 instead of being swallowed by the route (this used to silently catch-all under the old proxy literal path)

Croway and others added 2 commits September 4, 2026 09:47
…ial CamelHttpUrl

The example was broken in three ways:
- The README's curl --proxy command never reached the route: servlet
  containers normalize an absolute-form request line down to just the
  path, discarding the target host, so the request never matched
  platform-http:proxy/*.
- toD("${headers.CamelHttpUrl}") used the incoming request's own URL
  (CamelHttpUrl is set from request.getRequestURL(), i.e. this
  application's own address), causing the route to call itself in an
  infinite loop until the HTTP connection pool exhausted (503s).
- The consumer path literal "proxy" collides with a reserved marker in
  camel-platform-http that turns the endpoint into a catch-all consumer
  for a Host-header-based forward proxy - a mode only implemented by
  the Vert.x platform-http engine, not by camel-platform-http-starter
  (the servlet/Spring MVC engine this example uses). Left as-is it
  silently degrades into an unguarded catch-all matching unrelated
  paths instead of 404ing.

Redesigned as a real path-based reverse proxy: requests under
/reverse-proxy/** are forwarded to a configurable backend
(reverse-proxy.target-base-uri) using camel-http's bridgeEndpoint mode,
which appends CamelHttpPath/CamelHttpQuery onto the fixed target
automatically instead of trusting a self-referential header.

Verified end-to-end against httpbin.org: query strings, root path, and
trailing-slash requests all forward correctly, and unrelated paths now
404 instead of being swallowed by the route.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE
Use setHeader with a Simple/OGNL expression (${header.CamelHttpPath.substring(n)},
which invokes the real java.lang.String.substring(int) per Camel's OGNL support)
instead of a Java lambda Processor, keeping the route declarative.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tgb2b9DSh1ncG7C82rwzsE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant