question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hi there, i dont know if i am right here, but i have not found anything according to my problem in the web. i have to use elasticsearch in python from behind a proxy server. how can i pass down the proxy setting to elasticsearch. i tried something like that without success.

es = Elasticsearch([es_url], _proxy = "http://proxyurl:port", _proxy_headers = { 'basic_auth': 'USERNAME:PASSWORD' })
res = es.search(index=index, body=request, search_type="count")

any help would be very nice. thanks

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:27 (9 by maintainers)

github_iconTop GitHub Comments

5reactions
honzakralcommented, May 11, 2016

Sorry, my bad, it should be:

from elasticsearch import 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([es_url], connection_class=MyConnection, proxies = {'https': 'http://user:pw@proxy.org:port'})

print(es.info())

I forgot the self in __init__.

1reaction
honzakralcommented, Sep 28, 2015

this should work:

from elasticsearch import RequestsHttpConnection

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

es = Elasticsearch([es_url], connection_class=MyConnection, proxies = {'https': 'http://user:pw@proxy.org:port'})


print(es.info())
Read more comments on GitHub >

github_iconTop Results From Across the Web

Find Proxy Settings on Your Computer (for Local Testing ...
In any Windows version, you can find the proxy settings via the Control Panel on your computer. Click on Start and open the...
Read more >
How to Set Up a Proxy Server on Your PC, Mac, or Web Browser
How to find proxy settings in Windows · Click Start and select Settings (the gear icon) from the Start menu. · Choose Network...
Read more >
What is a Proxy Server and How Does it Work? - Varonis
A proxy server acts as a gateway between you and the internet. It's an intermediary server separating end users from the websites they...
Read more >
How to set a proxy server in Chrome, Firefox, Edge, and Opera
To change the Google Chrome proxy settings, first, click or tap on the “Customize and control Google Chrome” button from the browser's top-right ......
Read more >
How to Set Up a Proxy in Windows 10 - Dummies.com
Open Settings. · Click Network & Internet. · Click Proxy. · In the Manual Proxy Setup section, set the Use a Proxy Server...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found