Skip to content

SOLR-18537: Proxy requests to a node via X-Solr-targetNode - #5112

Open
dsmiley wants to merge 11 commits into
apache:mainfrom
dsmiley:SOLR-18537-proxyRequestsByHeader
Open

dsmiley wants to merge 11 commits into
apache:mainfrom
dsmiley:SOLR-18537-proxyRequestsByHeader

Conversation

@dsmiley

@dsmiley dsmiley commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/SOLR-18537

It can be very useful for Solr to proxy requests to another node, specified in a header or param. The intended scenario is when there's an HTTP proxy in front of Solr, and the backing Solr nodes aren't directly reachable. Solr is doing that now for a few admin endpoints that have already been coded for it, using GenericV1RequestProxy internally (e.g. for logging, info, ...). The issue here instead proposes a generic mechanism that doesn't require Solr handlers to be coded any differently.

Header or param.
Useful to reach a specific node.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@dsmiley

dsmiley commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

FYI I've been using this for awhile at work.
Marking as Draft because needs a test and documentation.

Are there security concerns here? I don't think so. This is live-nodes only.

code: use Solr's URL param parsing
@github-actions github-actions Bot added documentation Improvements or additions to documentation test-framework tests labels Oct 20, 2026
@dsmiley
dsmiley marked this pull request as ready for review October 20, 2026 20:42
@janhoy
janhoy requested a balanced review from Copilot October 21, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@janhoy janhoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I delegate review to Copilot who is probably better at servlet spec than me. I do like the general solution and I believe the security aspect is handled so so far a LGTM from me from 10.000 ft

@janhoy janhoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some manual review comments as I'm out of copilot credit...

Comment thread solr/core/src/java/org/apache/solr/servlet/NodeTargetProxyFilter.java Outdated
Comment thread solr/core/src/java/org/apache/solr/servlet/NodeTargetProxyFilter.java Outdated
zkStateReader.getBaseUrlForNodeName(resolvedNode) + ServletUtils.getPathAfterContext(req);
String queryString = req.getQueryString();
if (queryString != null) {
url = url + "?" + queryString;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the URL class for url manipulation instead of String?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm rather sympathetic. We have an addiction to untyped Strings, and it'd behove us to adopt URI as Jetty has done. I'll push an improvement.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Caller identity preservation and request-routing correctness need correction before approval.

5 open issues

Review effort: Balanced

Comment on lines +99 to +101
HttpClient httpClient =
((HttpJettySolrClient) cores.getDefaultHttpSolrClient()).getHttpClient();
HttpSolrProxy.doHttpProxy(httpClient, req, resp, url);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm investigating this separately.

Comment thread solr/core/src/java/org/apache/solr/servlet/NodeTargetProxyFilter.java Outdated
Comment thread solr/core/src/java/org/apache/solr/servlet/NodeTargetProxyFilter.java Outdated
Comment thread solr/core/src/java/org/apache/solr/servlet/NodeTargetProxyFilter.java Outdated
@dsmiley

dsmiley commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

It's really remarkable how much this PR has improved/evolved as a result of such peer-review/scrutiny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants