Plugin installation behind authenticated proxy is not working in Logstash version 5.5.0

Hi all,

I am trying to install logstash-filter-plugin behind authenticated proxy and failed to do so. So far I have used following methods

Setting environment variable HTTP[S]_PROXY does not work with following error
Command :
JARS_SKIP='true' DEBUG=1 /usr/share/logstash/bin/logstash-plugin install logstash-filter-translate
Error:
URI::InvalidURIError: bad URI(is not URI?): http://user:password@proxy.com:8080
split at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/uri/common.rb:176
parse at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/uri/common.rb:210
parse at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/uri/common.rb:747
URI at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/uri/common.rb:994
extract_proxy_values_from_uri at /usr/share/logstash/lib/pluginmanager/proxy_support.rb:47
configure_proxy at /usr/share/logstash/lib/pluginmanager/proxy_support.rb:69
(root) at /usr/share/logstash/lib/pluginmanager/main.rb:26

2a. Using Jruby J-Dhttp proxy settings is also not working
Command :
JARS_SKIP='true' JRUBY_OPTS='-J-Dhttps.proxyHost=user:password@proxy.com -J-Dhttps.proxyPort=8080 -J-Dhttp.proxyHost=user:password:proxy.com -J-Dhttp.proxyPort=8080' DEBUG=1 /usr/share/logstash/bin/logstash-plugin install logstash-filter-translate
Error :
DEBUG: exec /usr/share/logstash/vendor/jruby/bin/jruby /usr/share/logstash/lib/pluginmanager/main.rb install logstash-filter-translate
Looking if package named: logstash-filter-translate exists at https://artifacts.elastic.co/downloads/logstash-plugins/logstash-filter-translate/logstash-filter-translate-5.5.0.zip
Network error, skipping Elastic pack, exception: initialize: name or service not known
Validating logstash-filter-translate
Unable to download data from https://rubygems.org - SocketError: initialize: name or service not known (https://rubygems.org/latest_specs.4.8.gz)
ERROR: Installation aborted, verification failed for logstash-filter-translate

On further diagnosis, I found that installer is sending a DNS query for "user:password@proxy.com" which is obviously failing due to malformed query.

2b. Command :
JARS_SKIP='true' JRUBY_OPTS='-J-Dhttps.proxyHost=proxy.com -J-Dhttps.proxyPort=8080 -J-Dhttps.proxyUser=user -J-Dhttps.proxyPassword=password -J-Dhttp.proxyHost=proxy.com -J-Dhttp.proxyPort=8080 -J-Dhttp.proxyUser=user -J-Dhttp.proxyPassword=password' DEBUG=1 /usr/share/logstash/bin/logstash-plugin install logstash-filter-translate
Error:
DEBUG: exec /usr/share/logstash/vendor/jruby/bin/jruby /usr/share/logstash/lib/pluginmanager/main.rb install logstash-filter-translate
Looking if package named: logstash-filter-translate exists at https://artifacts.elastic.co/downloads/logstash-plugins/logstash-filter-translate/logstash-filter-translate-5.5.0.zip
Net::HTTPServerException: 407 "Proxy Authentication Required"
error! at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:2641
value at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:2650
connect at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:796
do_start at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:756
start at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:745
start at /usr/share/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:557
start at /usr/share/logstash/lib/pluginmanager/utils/http_client.rb:13
remote_file_exist? at /usr/share/logstash/lib/pluginmanager/utils/http_client.rb:31
get_installer_for at /usr/share/logstash/lib/pluginmanager/pack_fetch_strategy/repository.rb:32
create at /usr/share/logstash/lib/pluginmanager/install_strategy_factory.rb:18
each at org/jruby/RubyArray.java:1613
create at /usr/share/logstash/lib/pluginmanager/install_strategy_factory.rb:17
execute at /usr/share/logstash/lib/pluginmanager/install.rb:30
run at /usr/share/logstash/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:67
execute at /usr/share/logstash/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/subcommand/execution.rb:11
run at /usr/share/logstash/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:67
run at /usr/share/logstash/vendor/bundle/jruby/1.9/gems/clamp-0.6.5/lib/clamp/command.rb:132
(root) at /usr/share/logstash/lib/pluginmanager/main.rb:48

Somehow, in this scenario it is not taking username and password settings.
I tried older version too with no luck. Please guide me where I am wrong.

Thanks and Regards
Lalit

A kind of dirty hack, I provided proxy username and password directly into file vendor/jruby/lib/ruby/1.9/net/http.rb and got problem solved. In process learned ruby a little bit
Thanks and Regards
Lalit

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.