/ / Erreur de connexion Django Haystack lors de l'utilisation de l'authentification http - django, elasticsearch, django-haystack, authentification http, pyelasticsearch

Erreur de connexion Django Haystack lors de l'utilisation de l'authentification http - django, elasticsearch, django-haystack, authentification http, pyelasticsearch

J'utilise Haystack pour me connecter et interagir avec une installation d’élasticsearch. Elasticsearch est installé sur un boîtier différent du serveur Web principal.

J'ai configuré l'authentification HTTP sur la boîte de dialogue elasticsearch à l'aide de nginx. Ceci permet d'empêcher l'accès non autorisé à elasticsearch.

La configuration Haystack ressemble à ceci:

HAYSTACK_CONNECTIONS = {
"default": {
"ENGINE": "haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine",
"URL": "http://USERNAME:PASSWORD@DOMAIN:PORT/",
"INDEX_NAME": "haystack",
},
}

Avec cette installation, je reçois une erreur de connexion:

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")))

Si je désactive l’authentification HTTP et mets à jour l’URL en conséquence http://DOMAIN:PORT/ il se connecte sans problème.

Se pourrait-il que Haystack (ou elasticsearch-py (http://www.elasticsearch.org/guide/en/elasticsearch/client/python-api/current/) n’autorise pas l’utilisation de l’authentification HTTP dans l’URL? Je remarque qu’il s’agit d’un problème lié à Solr - Authentification Solr (avec Django Haystack)

Réponses:

5 pour la réponse № 1

Pour les autres avec le même problème, ajoutez kwargs à config:

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

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