# Connecting to ES via a http proxy in perl client

**URL:** <https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423>\
**Category:** Elasticsearch\
**Created:** [October 24, 2014, 4:24pm UTC](https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423 "2014-10-24T16:24:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Van\_Workum](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@Kevin\_Van\_Workum](https://discuss.elastic.co/u/Kevin_Van_Workum)\
**Post date:** [October 24, 2014, 4:24pm UTC](https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423/1 "2014-10-24T16:24:00Z")

</div>

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](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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/79f08fa4-6bac-4876-8c92-85f3e89a9220%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79f08fa4-6bac-4876-8c92-85f3e89a9220%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 28, 2014, 9:25am UTC](https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423/2 "2014-10-28T09:25:29Z")

</div>

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} = "[http://proxy:3128](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: [HTTP::Tiny - A small, simple, correct HTTP/1.1 client - metacpan.org](https://metacpan.org/pod/HTTP::Tiny#PROXY-SUPPORT)

This should work:

> $ENV{http\_proxy} = "[http://proxy:3128](http://proxy:3128)";  
> $e = Search::Elasticsearch-\>new( nodes =\> '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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/453ec592-e3c9-4ff4-8f5a-8e71bab901d5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/453ec592-e3c9-4ff4-8f5a-8e71bab901d5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kevin\_Van\_Workum](https://avatars.discourse-cdn.com/v4/letter/k/e0b2c6/32.png) [@Kevin\_Van\_Workum](https://discuss.elastic.co/u/Kevin_Van_Workum)\
**Post date:** [October 28, 2014, 1:52pm UTC](https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423/3 "2014-10-28T13:52:25Z")

</div>

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} = "[http://proxy:3128](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](https://metacpan.org/pod/HTTP::Tiny#PROXY-SUPPORT)
> 
> This should work:
> 
> > $ENV{http\_proxy} = "[http://proxy:3128](http://proxy:3128)";  
> > $e = Search::Elasticsearch-\>new( nodes =\> 'node1:9200' );

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

$e = Search::Elasticsearch-\>new ( nodes =\> 'node1:9200', handle\_args =\> {  
proxy =\> '[http://proxy:3128](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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/0fed1321-7c27-4938-ad80-9a840b7b6fef%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0fed1321-7c27-4938-ad80-9a840b7b6fef%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:53am UTC](https://discuss.elastic.co/t/connecting-to-es-via-a-http-proxy-in-perl-client/20423/4 "2017-07-06T00:53:25Z")

</div>


