# Shipping logs via Proxy with Logstash

**URL:** <https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723>\
**Category:** Logstash\
**Created:** [July 1, 2015, 1:14pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723 "2015-07-01T13:14:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [July 1, 2015, 1:14pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/1 "2015-07-01T13:14:21Z")

</div>

Hi,

How do I tell Logstash to ship logs via a proxy?  
I searched and searched, but could not find any documentation about shipping via a proxy. Maybe sending data through proxy is simply not supported at this time?

Thanks,  
Otis

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 1, 2015, 1:26pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/2 "2015-07-01T13:26:29Z")

</div>

Which output plugin are you using to ship the logs?

---

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [July 1, 2015, 5:13pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/3 "2015-07-01T17:13:17Z")

</div>

Hi Magnus,

Trying to use the Elasticsearch output.  
I don't think that output itself has any support for sending data through a proxy, or does it?

I was thinking Logstash must be able to get data out via an HTTP proxy in general.... but maybe it simply doesn't have tht functionality?

Thanks,  
Otis

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [July 1, 2015, 6:07pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/4 "2015-07-01T18:07:04Z")

</div>

I have no idea if it's supported. I'd be surprised if the underlying HTTP library didn't support it so it's quite possibly just a matter of exposing the configuration.

---

<div class="post-metadata">

**Author:** ![kfehlker](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kfehlker](https://discuss.elastic.co/u/kfehlker)\
**Post date:** [July 8, 2015, 3:51pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/5 "2015-07-08T15:51:08Z")

</div>

I am having the same problem. I have even added "set -x" in "./bin/logstash.sh.lib" to see what gets passed to Ruby. It looks fine to me (servernames and tokens replaced for confidentiality-reasons):

```
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ export LS_JAVA_OPTS="-Dhttp.proxyHost=proxy-srv.mycorp.net -Dhttp.proxyPort=8080"
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ ./bin/logstash -f hsbx01-sematext.conf            
..
+ JAVA_OPTS='-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -Djava.awt.headless=true -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Dhttp.proxyHost=proxy-srv.mycorp.net -Dhttp.proxyPort=8080 -Xmx500m'
..
+ ruby_exec /opt/oracle/logstash-1.5.1/lib/bootstrap/environment.rb logstash/runner.rb agent -f hsbx01-sematext.conf
..
++ for i in '$JAVA_OPTS'
++ printf %s ' -J-Dhttp.proxyHost=proxy-srv.mycorp.net'
++ for i in '$JAVA_OPTS'
++ printf %s ' -J-Dhttp.proxyPort=8080'
++ for i in '$JAVA_OPTS'
++ printf %s ' -J-Xmx500m'
+ exec /opt/oracle/logstash-1.5.1/vendor/jruby/bin/jruby --1.9 -J-XX:+UseParNewGC -J-XX:+UseConcMarkSweepGC -J-Djava.awt.headless=true -J-XX:CMSInitiatingOccupancyFraction=75 -J-XX:+UseCMSInitiatingOccupancyOnly -J-Dhttp.proxyHost=proxy-srv.mycorp.net -J-Dhttp.proxyPort=8080 -J-Xmx500m /opt/oracle/logstash-1.5.1/lib/bootstrap/environment.rb logstash/runner.rb agent -f hsbx01-sematext.conf
Logstash startup completed
my Logstash-Test
Jul 08, 2015 5:42:29 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (org.apache.http.conn.HttpHostConnectException) caught when processing request to {}->http://logsene-receiver.sematext.com:80: Connect to logsene-receiver.sematext.com:80 [logsene-receiver.sematext.com/23.21.237.54, logsene-receiver.sematext.com/23.21.74.13] failed: Connection refused

```

Here is my Logstash-configuration:

```
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ cat hsbx01-sematext.conf
input {
  stdin { }
}

output {
  elasticsearch {
    protocol => "http" # you should not change this to https if you want to use SSL
    # ssl => "false" # if you want to use SSL/HTTPS
    host => "logsene-receiver.sematext.com"
    port => 80 # use 443 if you enable SSL
    index => "<stripped>" # your token
    manage_template => false
  }
}

```

However, I also tried a test script from some forum to test Ruby itself. Apparently, Ruby is able to communicate with outside world and even with the particular server that is configured in the Logstash-configuration:

```
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ cat conn-test.sh 
#!/bin/bash 
export JAVA_OPTS="-Dhttp.proxyHost=proxy-srv.mycorp.net -Dhttp.proxyPort=8080 -Dhttp.nonProxyHosts=*.dont.proxy.me" 
vendor/jruby/bin/jruby ./conn-test.rb 
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ cat conn-test.rb 
require 'net/http' 
require 'java' 
java_import java::lang::System 
uri=URI('http://logsene-receiver.sematext.com') 
puts "Proxy #{System.getProperty('http.proxyHost')}:#{System.getProperty('http.proxyPort')}" 
puts "Proxy exclusion: #{System.getProperty('http.nonProxyHosts')}" 
puts Net::HTTP.get(uri) 

HSBX01@my-server /opt/oracle/logstash-1.5.1 $ ./conn-test.sh 
Proxy proxy-srv.mycorp.net:8080 
Proxy exclusion: *.dont.proxy.me 
{"status":200,"name":"Sematext-Logsene","cluster_name":"elasticsearch","version":{"number":"1.4.4","build_hash":"c88f77ffc81301dfa9dfd81ca2232f09588bd512","build_timestamp":"2015-02-19T13:05:36Z","build_snapshot":false,"lucene_version":"4.10.3"},"tagline":"You Know, for Search"} 
HSBX01@my-server /opt/oracle/logstash-1.5.1 $ 

```

So I think I am missing something obvious, I just don't know yet what... Does anyone have an idea?

---

<div class="post-metadata">

**Author:** ![suyograo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suyograo/32/44898_2.png) [@suyograo](https://discuss.elastic.co/u/suyograo)\
**Post date:** [July 30, 2015, 11:52pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/6 "2015-07-30T23:52:18Z")

</div>

We added support for this in LS 1.5.3. For details see: [https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/199](https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/199)

Docs here: [https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-proxy](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-elasticsearch.html#plugins-outputs-elasticsearch-proxy)

---

<div class="post-metadata">

**Author:** ![falafel](https://avatars.discourse-cdn.com/v4/letter/f/34f0e0/32.png) [@falafel](https://discuss.elastic.co/u/falafel)\
**Post date:** [August 10, 2015, 5:01pm UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/7 "2015-08-10T17:01:04Z")

</div>

The new 1.5.3 proxy output feature seems to only apply to ElasticSearch. Is there a way to send http output to a specified proxy using only Logstash, with no ElasticSearch component?

According to a old [StackOverflow post](http://stackoverflow.com/questions/26136461/configuring-proxy-for-logstash) this kind of thing should work, but it doesn't:  
export LS\_JAVA\_OPTS="-Dhttp.proxyHost=[proxy.somesite.com](http://proxy.somesite.com) -Dhttp.proxyPort=1234 -Dhttps.proxyHost=[proxy.somesite.com](http://proxy.somesite.com) -Dhttps.proxyPort=1234"

---

<div class="post-metadata">

**Author:** ![geekpete](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geekpete/32/20409_2.png) [@geekpete](https://discuss.elastic.co/u/geekpete)\
**Post date:** [May 20, 2016, 6:49am UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/8 "2016-05-20T06:49:44Z")

</div>

In 5.0.0 ALPHA1, the ability to ship from Beats to Logstash via a SOCKS5 proxy was added as well.

---

<div class="post-metadata">

**Author:** ![Copper](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/copper/32/18468_2.png) [@Copper](https://discuss.elastic.co/u/Copper)\
**Post date:** [May 24, 2017, 2:12am UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/9 "2017-05-24T02:12:34Z")

</div>

I just have face this problem, that i use Logstash to ship logs to webhdfs through a proxy. I just use "export LS\_JAVA\_OPTS="-Dhttp.proxyHost=ur-proxy -Dhttp.proxyPort=ur-port", it work fine for logstash version 5.1

---

<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, 4:26am UTC](https://discuss.elastic.co/t/shipping-logs-via-proxy-with-logstash/24723/10 "2017-07-06T04:26:23Z")

</div>


