Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.
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

Description

@RatanShreshtha

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"),
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions