在 solr 中禁用配置编辑

Disable config edit in solr

我正在尝试禁用 solr 中的 configApi,我在一篇博客中读到它 "Disable the ConfigAPI if not in use, by running Solr with the system property disable.configEdit=true"。有人可以解释一下我们实际上是怎么做到的吗?

您在 Solr 启动文件中设置了系统属性。通常有一个名为SOLR_OPTS的参数,您可以在其中添加-Ddisable.configEdit=true。在使用 export SOLR_OPTS=.....

启动 solr 之前,您还应该能够在 shell 中进行设置

要保留来自 shell 的任何值,您应该在编辑 Solr 启动文件时使用 SOLR_OPTS="$SOLR_OPTS -Ddisable.configEdit=true"

来自与 Solr 捆绑的示例 solr.in.sh:

# Anything you add to the SOLR_OPTS variable will be included in the java
# start command line as-is, in ADDITION to other options. If you specify the
# -a option on start script, those options will be appended as well. Examples:
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoSoftCommit.maxTime=3000"
#SOLR_OPTS="$SOLR_OPTS -Dsolr.autoCommit.maxTime=60000"
#SOLR_OPTS="$SOLR_OPTS -Dsolr.clustering.enabled=true"

在 solr.in.cmd 中添加以下行并重新启动 SOLR 对我有用,

set SOLR_OPTS=%SOLR_OPTS% -Ddisable.configEdit=true

我们还可以通过执行以下 curl 命令来验证配置 API 是否被禁用,这将导致 403 禁止错误,

curl https://localhost:8983/solr/<core_name>/config -H "Accept: application/json" -H "Content-type:application/json" -d "{'set-user-property' : {'variable_name':'some_value'}}"