-
Notifications
You must be signed in to change notification settings - Fork 821
SOLR-18055 Use solr.ssl.enabled property for url scheme detection #4272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
507ee79
699423c
3d10e22
b4dbc3f
3509c36
8c66140
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| # See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc | ||
| title: Improved CloudSolrClient's urlScheme detection by using the scheme of provided Solr URLs, or looking at "solr.ssl.enabled". | ||
| title: Improved CloudSolrClient's http/https (SSL) detection by using the scheme of provided Solr URLs, or looking at the "solr.ssl.enabled" system property. Likewise improved Solr itself to consider this property as an alternative to the urlScheme cluster property. | ||
| type: changed | ||
| authors: | ||
| - name: Vishnu Priya Chandra Sekar | ||
| links: | ||
| - name: SOLR-18056 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18056 | ||
| - name: SOLR-18055 | ||
| url: https://issues.apache.org/jira/browse/SOLR-18055 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| import org.apache.solr.common.cloud.ZkStateReader; | ||
| import org.apache.solr.common.params.ShardParams; | ||
| import org.apache.solr.common.params.SolrParams; | ||
| import org.apache.solr.common.util.EnvUtils; | ||
| import org.apache.solr.common.util.ExecutorUtil; | ||
| import org.apache.solr.common.util.IOUtils; | ||
| import org.apache.solr.common.util.NamedList; | ||
|
|
@@ -109,6 +110,9 @@ public class HttpShardHandlerFactory extends ShardHandlerFactory | |
| // URL scheme to be used in distributed search. | ||
| static final String INIT_URL_SCHEME = "urlScheme"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious; was
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like [1] https://solr.apache.org/guide/solr/latest/configuration-guide/configuring-solr-xml.html
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Thanks for looking into it. |
||
|
|
||
| // system property to enable ssl or tls for communication within Solr | ||
| static final String SOLR_SSL_ENABLED = "solr.ssl.enabled"; | ||
|
|
||
| // The core size of the threadpool servicing requests | ||
| static final String INIT_CORE_POOL_SIZE = "corePoolSize"; | ||
|
|
||
|
|
@@ -227,12 +231,7 @@ private void initReplicaListTransformers(NamedList<?> routingConfig) { | |
| public void init(PluginInfo info) { | ||
| StringBuilder sb = new StringBuilder(); | ||
| NamedList<?> args = info.initArgs; | ||
| // note: the sys prop is only used in testing | ||
| this.scheme = getParameter(args, INIT_URL_SCHEME, System.getProperty(INIT_URL_SCHEME), sb); | ||
| if (this.scheme != null && this.scheme.endsWith("://")) { | ||
| this.scheme = this.scheme.replace("://", ""); | ||
| } | ||
|
|
||
| this.scheme = initUrlScheme(args, sb); | ||
| String strategy = | ||
| getParameter( | ||
| args, "metricNameStrategy", UpdateShardHandlerConfig.DEFAULT_METRICNAMESTRATEGY, sb); | ||
|
|
@@ -436,6 +435,23 @@ private String buildUrl(String url) { | |
| return url; | ||
| } | ||
|
|
||
| /** | ||
| * Get url scheme of host | ||
| * | ||
| * @return http or https or null | ||
| */ | ||
| private String initUrlScheme(NamedList<?> args, StringBuilder sb) { | ||
| final Boolean isSolrSslEnabled = EnvUtils.getPropertyAsBool(SOLR_SSL_ENABLED, null); | ||
| if (isSolrSslEnabled != null) { | ||
| return isSolrSslEnabled ? "https" : "http"; | ||
| } | ||
| String urlScheme = getParameter(args, INIT_URL_SCHEME, System.getProperty(INIT_URL_SCHEME), sb); | ||
| if (urlScheme != null && urlScheme.endsWith("://")) { | ||
| urlScheme = urlScheme.replace("://", ""); | ||
| } | ||
| return urlScheme; | ||
| } | ||
|
|
||
| @Override | ||
| public void initializeMetrics(SolrMetricsContext parentContext, Attributes attributes) { | ||
| solrMetricsContext = parentContext.getChildContext(this); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.