Configuring Proxy for Logstash

2019-08-15 01:58发布

I'm trying to run Logstash to send the output to Elasticsearch through a proxy. As far as I can tell there is no configuration for the output that would allow me to specify a proxy. Currently I use:

output {
  elasticsearch {
    protocol => "http"
    host => "es-dev.local"
    port => "9200"
    index => "logstash-analysis-%{+YYYY.MM.dd}"
    flush_size => "200"
    workers => "2"
    template_name => "logstash_per_index"
  }
}

elasticsearch_http also has no option for that. How can I use a proxy?

1条回答
Rolldiameter
2楼-- · 2019-08-15 02:47

Things are quite simple once you know that in the end it's all just plain Java...

In other words Logstash uses Java's system properties to make this work. Then the only piece left is knowing how to specify it. Using environment variable LS_JAVA_OPTS does the trick:

SET LS_JAVA_OPTS=-Dhttp.proxyHost=proxy.local -Dhttp.proxyPort=1337
logstash ...

The downside of this approach is that there can only be one proxy for all outputs. It's not possible to use the proxy for just one output or use different proxies for different outputs.

查看更多
登录 后发表回答