elasticsearch-labs icon indicating copy to clipboard operation
elasticsearch-labs copied to clipboard

chatbot-rag-app does not work for self-signed (local development)

Open liu-xiao-guo opened this issue 1 year ago • 1 comments

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:

  1. 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.
  1. 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

liu-xiao-guo avatar Dec 11 '23 14:12 liu-xiao-guo

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!

joemcelroy avatar Dec 12 '23 09:12 joemcelroy