-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Proxy settings #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, unfortunately our connection classes don't support proxy settings out of the box. The solution is to create your own and set it directly via Another, easier, option would be to just set the env variables (mentioned in http://www.python-requests.org/en/latest/user/advanced/#proxies) when using |
thanks for your fast answer. how can i set my connection class via requests?
thanks |
or do you mean something like?:
Sorry i am realy desperate for a solution to this problem.. |
this should work:
|
Thank you very much!! It works perfect!! |
It gives an error "name error" self not defined |
i want to do the same thing as svamet , but i think its because i am using python3.4 i am getting this error, but i cant get around it. |
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 |
Thankyou very much!! i should have figured it out :P |
After setting up the proxy as you devised now when i do:
|
You are trying to speak http to https port, could it be that you forgot |
yeah i thought that too but when i
|
and can you connect to the target just using Either way I am afraid this is out of scope of this library. First step would be to make your environment work with just plain |
I can connect to an *http * server over a proxy and every thing works fine but when i do this:
but when i access a local https server on the intranet then |
for any one who is having the same problem with request library |
and how to connect a cluster which behind nginx? |
@shenyan008 at that point all you have to do is specify connection parameters for that nginx - host and port should suffice |
@honzakral Thank you for your reply, your rely is so quick. |
@honzakral It's my bad, I set the sniff_on_start=true when creating the es instance, but I do not know why this setting will cause the problem |
what sniffing does is it inspects the cluster and uses the lost of nodes to do load balancing. Since you don't have direct access to the nodes (and use nginx to connect to them indirectly instead) you cannot use that method. See http://elasticsearch-py.readthedocs.io/en/master/#environment-considerations for more information |
@honzakral Thanks for your help, problem solved |
Shouldn't it be reading proxy settings form
Ran but elasticsearch-py doesn't seem to pick proxy from system proxy settings, the request doesn't hit the proxy server. I understand the temporary fix explained here but what is permanent fix for this? |
@kanihal if you just use the |
@honzakral Would it be possible for you to take a look at this issue ? elastic/elastic-transport-python#52 I have made request work with proxy and elasticsearch but cant get the library to work. Thanks a lot. |
@nilansaha I am sorry, I don't work on this project any more, but if I were to guess I'd say you just need to explicitly specify port |
Omg. Thank you so much @honzakral I really appreciate it. Its not over SSL so 443 did not work but then tried adding |
Hi, new version 8.x does not come with the "RequestsHttpConnection" option any more, so we need to use urllib3 every time, right? Is there a similar way to set the proxy parameter there? System variable doesn't seem to be working. |
Hi, |
I've talk to Elastic Team over my company and they offer this solution for HTTP proxy (HTTPS will not work) elastic/elastic-transport-python#53 (comment) This solution will work for Elasticsearch 8.X.X |
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.
any help would be very nice.
thanks
The text was updated successfully, but these errors were encountered: