Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

How can I use proxy to connect to elasticsearch ? #58

Closed
RatanShreshtha opened this issue Nov 2, 2018 · 4 comments
Closed

How can I use proxy to connect to elasticsearch ? #58

RatanShreshtha opened this issue Nov 2, 2018 · 4 comments

Comments

@RatanShreshtha
Copy link

I am trying to connect elasticsearch cluster when I am behind a corporate proxy maybe something like

from elasticsearch import Elasticsearch, RequestsHttpConnection


class MyConnection(RequestsHttpConnection):
    def __init__(self, *args, **kwargs):
        proxies = kwargs.pop("proxies", {})
        super(MyConnection, self).__init__(*args, **kwargs)
        self.session.proxies = proxies


es = Elasticsearch(
    ["https://url_to_elasticsearch"],
    connection_class=MyConnection,
    proxies=proxies,
    use_ssl=True,
    http_auth=("username", "password"),
)
@fxdgear
Copy link
Contributor

fxdgear commented Nov 5, 2018

@RatanShreshtha thanks for the issue.

Unfortuantly using urllib3 we don't support proxies yet, so as a work around you can use the requests library, similar to what you're suggesting.

for more reference please see:

@RatanShreshtha
Copy link
Author

I am not sure how can I use the above code snippet for elasticsearch-py-async as here the aiohttp lib is used.

@sethmlarson
Copy link
Contributor

Since we won't be adding new features to this library I'll be closing this. See #81 for more information. You can use a transparent HTTP proxy (as opposed to forwarding/tunnel) which should work fine with any client.

@qbit-git
Copy link

qbit-git commented Jun 8, 2021

AsyncElasticsearch cannot recognize http_proxy
Windows 10
ES 7.10

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants