I tried to use this code to utilize the python requests library to connect through a corporate HTTP proxy to elasticsearch by specifying the HTTPS_PROXY environment variable, but it seems like when I try to connect over HTTPS the HTTPS_PROXY variable is getting ignored
from elasticsearch import Elasticsearch, RequestsHttpConnection
es = Elasticsearch([es_url], connection_class=RequestsHttpConnection)
I can't use HTTP because our elasticsearch is hosted on HTTPS over port 443
My expectation is that the library should attempt to connect through the HTTP proxy, however it seems like it is still attempting to connect to the host directly without going through the corporate proxy
Basically to connect to Elasticsearch Remote server with the
SSH(HTTPS) protection you will needSSL certificatefile which is usually generated inside the Elasticsearch configuration folder like this:C:\elastic-stack\elasticsearch-8.7.1-windows-x86_64\elasticsearch-8.7.1\config\certs\http_ca.crtI don't know how it works with
Python, but I can tell how it works withJava. But there is small issue, certificate signed by a Certificate Authority (CA) which is not recognized by theJava truststore.To resolve this issue, you need to add the Elasticsearch server's SSL certificate to the truststore used by Java application. To do so, write the following command in Terminal:
And finally
Java clientlooks like this, which makes the connection with Elastic and prints out the relevant connection status:If you do everything correct, then you should see similar result like this: