gpt4 book ai didi

使用http身份验证的Django Haystack连接错误

转载 作者:行者123 更新时间:2023-12-01 02:42:20 24 4
gpt4 key购买 nike

我正在使用 Haystack 连接 elasticsearch 安装并与之交互。 Elasticsearch 安装在与主网络服务器不同的机器上。

我已经使用 nginx 在 elasticsearch box 上设置了 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)

最佳答案

对于有同样问题的其他人,将 kwargs 添加到配置中:

'KWARGS': {
'port': parsed.port,
'http_auth': (parsed.username, parsed.password),
}

参见:https://github.com/toastdriven/django-haystack/issues/1046

关于使用http身份验证的Django Haystack连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27677681/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com