Connecting to ES via a http proxy in perl client

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Connecting to ES via a http proxy in perl client

Kevin Van Workum
I'm trying to connect to my ES via a proxy using a client written in perl. What's the best way to do this?

Here's what I have, and it works, but I suspect there's a more straight forward approach:

$e = Search::Elasticsearch->new(
   cxn
=> 'LWP',
   nodes
=> 'node1:9200' );

$ENV
{HTTP_proxy} = "http://proxy:3128";
$e
->transport->cxn_pool->next_cxn->handle->env_proxy;




--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/79f08fa4-6bac-4876-8c92-85f3e89a9220%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to ES via a http proxy in perl client

Clinton Gormley-3
Hi Kevin

On Friday, 24 October 2014 18:24:00 UTC+2, Kevin Van Workum wrote:
I'm trying to connect to my ES via a proxy using a client written in perl. What's the best way to do this?

Here's what I have, and it works, but I suspect there's a more straight forward approach:

$e = Search::Elasticsearch->new(
   cxn
=> 'LWP',
   nodes
=> 'node1:9200' );

$ENV
{HTTP_proxy} = "<a href="http://proxy:3128" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128\46sa\75D\46sntz\0751\46usg\75AFQjCNENHehJddBBh_WRN4Ufdm9VkobAdw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128\46sa\75D\46sntz\0751\46usg\75AFQjCNENHehJddBBh_WRN4Ufdm9VkobAdw';return true;">http://proxy:3128";
$e
->transport->cxn_pool->next_cxn->handle->env_proxy;


You should be able to do this using the default Cxn backend (HTTP::Tiny).  I haven't tried proxies but, according to the HTTP::Tiny docs, proxies are supported: https://metacpan.org/pod/HTTP::Tiny#PROXY-SUPPORT

This should work:

 
$ENV{http_proxy} = "http://proxy:3128";
$e 
= Search::Elasticsearch->newnodes => 'node1:9200' );
 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/453ec592-e3c9-4ff4-8f5a-8e71bab901d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Connecting to ES via a http proxy in perl client

Kevin Van Workum


On Tuesday, October 28, 2014 5:25:29 AM UTC-4, Clinton Gormley wrote:
Hi Kevin

On Friday, 24 October 2014 18:24:00 UTC+2, Kevin Van Workum wrote:
I'm trying to connect to my ES via a proxy using a client written in perl. What's the best way to do this?

Here's what I have, and it works, but I suspect there's a more straight forward approach:

$e = Search::Elasticsearch->new(
   cxn
=> 'LWP',
   nodes
=> 'node1:9200' );

$ENV
{HTTP_proxy} = "<a href="http://proxy:3128" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128\46sa\75D\46sntz\0751\46usg\75AFQjCNENHehJddBBh_WRN4Ufdm9VkobAdw';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128\46sa\75D\46sntz\0751\46usg\75AFQjCNENHehJddBBh_WRN4Ufdm9VkobAdw';return true;">http://proxy:3128";
$e
->transport->cxn_pool->next_cxn->handle->env_proxy;


You should be able to do this using the default Cxn backend (HTTP::Tiny).  I haven't tried proxies but, according to the HTTP::Tiny docs, proxies are supported: <a href="https://metacpan.org/pod/HTTP::Tiny#PROXY-SUPPORT" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmetacpan.org%2Fpod%2FHTTP%3A%3ATiny%23PROXY-SUPPORT\46sa\75D\46sntz\0751\46usg\75AFQjCNH1G5nqU4TBgCMuxT1FYiwOL6RdWw';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fmetacpan.org%2Fpod%2FHTTP%3A%3ATiny%23PROXY-SUPPORT\46sa\75D\46sntz\0751\46usg\75AFQjCNH1G5nqU4TBgCMuxT1FYiwOL6RdWw';return true;">https://metacpan.org/pod/HTTP::Tiny#PROXY-SUPPORT

This should work:

 
$ENV{http_proxy} = "<a href="http://proxy:3128/" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNE5pffz0IUIFNDIs2z6VQkXQ7uJjA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fproxy%3A3128%2F\46sa\75D\46sntz\0751\46usg\75AFQjCNE5pffz0IUIFNDIs2z6VQkXQ7uJjA';return true;">http://proxy:3128";
$e 
= Search::Elasticsearch->newnodes => 'node1:9200' );
 

Yep, that works. Thanks. One can also do this:

$e = Search::Elasticsearch->new ( nodes => 'node1:9200', handle_args => { proxy => 'http://proxy:3128' } );

 

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/0fed1321-7c27-4938-ad80-9a840b7b6fef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.