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

Feature: Support for proxy parameter in ElasticSearch client

Open sebastien opened this issue 2 years ago • 3 comments
trafficstars

Currently, there is no way to specify HTTP proxy urls for the ElasticSearch client to use when performing requests. Although issue #275 is marked as closed, there is no evidence of a solution implemented and supported by the client. We have tried to apply the recommended solutions, but none of the following have worked:

  • Using node_class="requests" or node_class=RequestsHttpNode along with HTTP_PROXY and HTTPS_PROXY environment variables set
  • Using a custom subclass of RequestsHttpNode to set the proxies at object construction

In both cases, requests were not performed through the given proxy URL.

We propose to the addition of a proxy parameter (or a proxy_http, proxy_https parameter set) to support the definition of a proxy to be used by a transport backend.

sebastien avatar May 10 '23 05:05 sebastien

Scratching my head on this one as well. The urllib3 class was basically pieced together in this module and buried. Proxy settings are a standard feature w/ even the most basic web clients. Based on previous versions, it actually looks like it was removed. Was this on purpose?

picheljitsu avatar Nov 21 '23 23:11 picheljitsu

Hello! Sorry for the delay here. Nothing was removed - in fact the Elasticsearch Python client never supported proxies out of the box. Since elasticsearch-py 8.x relies on https://github.com/elastic/elastic-transport-python/ the workaround has changed and is now https://github.com/elastic/elastic-transport-python/issues/53#issuecomment-1447903214.

I don't have immediate plans to add proxy support but the feature request makes sense so I'm leaving this open.

pquentin avatar Nov 22 '23 06:11 pquentin

It seems clear that each version has evolved to make it harder to use a proxy through each iteration. This is like contemplating whether it's a good idea to add rear-view mirrors into a car.

picheljitsu avatar Jan 11 '24 16:01 picheljitsu