Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support JVM proxy settings for Java #124

Open
gtback opened this issue May 20, 2015 · 7 comments
Open

Support JVM proxy settings for Java #124

gtback opened this issue May 20, 2015 · 7 comments

Comments

@gtback
Copy link

gtback commented May 20, 2015

It would be great if vagrant-proxyconf could support the http.proxyHost, http.proxyPort, and http.nonProxyHosts (along with HTTPS and FTP) options to the JVM.

Ref: http://docs.oracle.com/javase/8/docs/technotes/guides/net/proxies.html

I'm not sure the best way to set these (via environment variables such as JAVA_OPTS, perhaps?), or if they need to be explicitly passed to JVM invocations. I'm not that experienced with either Ruby or Java, but I'm happy to help out any way I can.

Background: I'm trying to install ElasticSearch plugins using Ansible (on machines both behind a proxy and not). While I could (and probably will in the short term) manually tweak the command-line invocation of the plugin command for proxy environments, it would be great if this was handled transparently by vagrant-proxyconf, which I'm using for other proxy-related settings on this project.

@tmatilai
Copy link
Owner

I'm afraid that this is impossible to do in a generic way. It totally depends how you invoke the JVM. While many scripts honor JAVA_OPTS or something like it, they also set/override it in their configuration file. It's really pity java doesn't support the standard environment variables here.

So I believe you have to set the JVM parameters via your own provisioner when you configure the application itself. If someone has more insight, please comment and we'll reopen the issue.

@gtback
Copy link
Author

gtback commented Jul 29, 2015

Thanks, @tmatilai. It's unfortunate that there's not a good way to do this in Java; not the fault of vagrant-proxyconf though. 😃

@tknerr
Copy link

tknerr commented Jan 21, 2016

@gtback just stumbled over elatsicsearch plugin installation behind a corp proxy as well, and finally found my way here.

So there is one thing that seems to work generically, namely the _JAVA_OPTIONS env var:
http://stackoverflow.com/a/2966629/2388971

Putting this to /etc/environment (or make sure its otherwise set in the ENV while the provisioner runs) made it work:

_JAVA_OPTIONS='-Dhttp.proxyHost=foo.com -Dhttp.proxyPort=3128 -Dhttps.proxyHost=foo.com -Dhttps.proxyPort=3128'

Thought this would be a useful addition to set in the env via vagrant-proxyconf.

@tknerr
Copy link

tknerr commented Jan 21, 2016

One more thing: this would probably be something that should always be set as part of configure_env_proxy.rb, instead of detecting for java first.

Why? Because a common use case is to first install java then run a java app (e.g. the elasticsearch plugin command) within a single provisioner run.

@tmatilai
Copy link
Owner

Oh, that's interesting! I have never came across that variable before.

I'll reopen the issue and wait for a pull request. =)
Just be sure to append and not replace the original _JAVA_OPTIONS.

@tmatilai tmatilai reopened this Jan 21, 2016
@tknerr
Copy link

tknerr commented Jan 21, 2016

We might even want to set

  • _JAVA_OPTIONS for java apps (java.exe)
  • JAVAWS_VM_ARGS for java webstart apps
  • _JPI_VM_OPTIONS for java applets (javaw.exe)

See here:
http://stackoverflow.com/a/9677804/2388971

@tknerr
Copy link

tknerr commented Jan 21, 2016

@tmatilai +1 for appending (or even better: prepending? -- not sure how java deals with that...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants