【发布时间】:2015-02-24 23:29:41
【问题描述】:
我正在使用 Haystack 与安装的 elasticsearch 进行连接和交互。 Elasticsearch 安装在与主网络服务器不同的盒子上。
我已经使用 nginx 在 elasticsearch 框上设置了 HTTP 身份验证。这是为了阻止对 elasticsearch 的未经授权的访问。
Haystack 配置如下所示:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://USERNAME:PASSWORD@DOMAIN:PORT/',
'INDEX_NAME': 'haystack',
},
}
通过这个设置我得到一个连接错误:
elasticsearch.exceptions.ConnectionError: ConnectionError(('Connection aborted.',
gaierror(-2, 'Name or service not known'))) caused by: ProtocolError(('Connection
aborted.', gaierror(-2, 'Name or service not known')))
如果我关闭 HTTP 身份验证并将 URL 相应地更新为 http://DOMAIN:PORT/,它可以毫无问题地连接。
可能是 Haystack(或 elasticsearch-py (http://www.elasticsearch.org/guide/en/elasticsearch/client/python-api/current/) 不允许在 URL 中使用 HTTP 身份验证?我注意到这是 Solr 的问题 - Solr authentication (using Django Haystack)
【问题讨论】:
标签: django elasticsearch django-haystack http-authentication pyelasticsearch