elasticsearch-labs
elasticsearch-labs copied to clipboard
chatbot-rag-app does not work for self-signed (local development)
For self-signed environment, the code does not work. we need to set the certificate in order to establish a connection with Elasticsearch. There are two places to change:
- index_data.py
ELASTCSEARCH_CERT_PATH = "/usr/share/certs/http_ca.crt"
if ELASTICSEARCH_URL:
elasticsearch_client = Elasticsearch(
hosts=[ELASTICSEARCH_URL],
ca_certs = ELASTCSEARCH_CERT_PATH,
verify_certs = True
)
This adds the certificate info into the connection.
- elasticsearch-client.py
ELASTCSEARCH_CERT_PATH = "/usr/share/certs/http_ca.crt"
if ELASTICSEARCH_URL:
elasticsearch_client = Elasticsearch(
hosts=[ELASTICSEARCH_URL],
ca_certs = ELASTCSEARCH_CERT_PATH,
verify_certs = True
)
We can index the data using the command like:
docker run \
--volume="$PWD/http_ca.crt:/usr/share/certs/http_ca.crt:ro" \
--rm --env-file .env chatbot-rag-app flask create-index
and we can run the frondend like:
docker run \
--volume="$PWD/http_ca.crt:/usr/share/certs/http_ca.crt:ro" \
--rm -p 4000:4000 --env-file .env -d chatbot-rag-app
Thanks! For now we have focused on two scenarios: cloud + local instance with security turned off.
An incremental improvement will be to add a heading for when you need to use the self-signed cert and allow the developer to customise the code to accommodate it. Happy for you to add that heading to the readme in a PR.
Will keep this issue open in case there are more developers who want this support. If you do, please react / comment on the issue!