问题描述
从v2.0开始Elasticsearch默认仅在localhost上进行监听,但是我想在localhost之外提出请求。
Starting from v2.0 Elasticsearch is listening only on localhost by default, but I'd like to make request outside localhost.
例如,像这样的请求被允许:
For example, a request like this is allowed:
http:// localhost:9200 /
但这不是:
http:// server_name:9200 /
(从服务器,例如:同一台局域网中的本地计算机)。
http://server_name:9200/
(from outside of the server, eg: a local computer in the same LAN).
感谢您的帮助。
推荐答案
将elasticsearch.yml文件重命名为configuration文件夹中的elasticsearch.json,然后添加:
Rename the elasticsearch.yml file to elasticsearch.json inside config folder and add:
{
"network" : {
"host" : "10.0.0.4"
}
}
另一个选项是使用ES_JAVA_OPTS或者弹性搜索命令的参数从外部提供设置,例如:
Another option is to provide the settings externally either using the ES_JAVA_OPTS or as parameters to the elasticsearch command, for example:
$ elasticsearch -Des.network.host = 10.0.0.4
另一个选项是设置es.default。前缀而不是es。前缀,这意味着默认设置将仅在配置文件中未显式设置时使用。
Another option is to set es.default. prefix instead of es. prefix, which means the default setting will be used only if not explicitly set in the configuration file.
另一个选项是使用 $ {。 ..}
配置文件中的符号将解析为环境设置,例如:
Another option is to use the ${...}
notation within the configuration file which will resolve to an environment setting, for example:
{
"network" : {
"host" : "${ES_NET_HOST}"
}
}
可以使用系统属性从外部设置配置文件的位置:
The location of the configuration file can be set externally using a system property:
$弹性搜索-Des.config = / path / to / config / file
有关更多信息,请查看
For more info, check out https://www.elastic.co/guide/en/elasticsearch/reference/1.4/setup-configuration.html
这篇关于如何在Elasticsearch 2.0中启用远程访问/请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!