tmatilai / vagrant-proxyconf

Vagrant plugin that configures the virtual machine to use proxies
MIT License
531 stars 74 forks source link

Disable proxy settings in provisioned box #167

Closed vladonemo closed 5 years ago

vladonemo commented 6 years ago

We use this plugin to setup the proxy in our vagrant boxes. Instead of putting the configuration to the vagrant file, we use the env. variables (on the host OS) for this purpose: HTTP_PROXY=proxyurl HTTPS_PROXY=proxyurl VAGRANT_HTTP_PROXY=proxyurl VAGRANT_HTTPS_PROXY=proxyurl

After the box is provisioned with this env. variables, how do we clear out the proxy settings in the box? (apt, yum, git, env. variables in the guest OS ...) It doesn't simply work by clearing out the env. variables in the host OS and reloading the box. My understanding is that vagrant-proxyconf doesn't do anything in this case at the moment.

tmatilai commented 6 years ago

If a variable is not specified, nothing is done. But if you set the value to an empty string, the configuration should be cleared. The readme tries to explain this.

vladonemo commented 6 years ago

Thanks for the answer. Now, how do you do this on Windows? My understanding is that it is not possible to create env. variable with empty value. In that case the variable is undefined. The only thing I could do is to set the value to a single space like this: set "HTTP_PROXY= "

but then I receive this error: dev: Configuring proxy for Yum... C:/HashiCorp/Vagrant/embedded/mingw64/lib/ruby/2.4.0/uri/rfc3986_parser.rb:67:in `split': bad URI(is not URI?): (URI::InvalidURIError)

tmatilai commented 6 years ago

Oh my... I didn't have any idea about that kind of restriction.

Should we support magic string "false" to do the same? That would be in line with Ruby based Vagrant config where the boolean value false does the same as empty string.

vladonemo commented 6 years ago

yes, for VAGRANT_HTTP_PROXY and VAGRANT_HTTPS_PROXY. That would be great!

tmatilai commented 6 years ago

OK. This should be a minor change in the code base. More effort will go into creating tests and documentation.

Travis tests are also broken and another PR is pending, so I'll try to put some love into the project this weekend.

vladonemo commented 6 years ago

Thaks a lot. I can help you out with the documentation. I don't speak Ruby much :)

AlexRadch commented 6 years ago

I have the same issue! How to workaround now?

tmatilai commented 6 years ago

Unfortunately the only workaround now would be to write the logic to the Vagrantfile, i.e. setting the variable in Ruby to false with whatever logic (for example when the env var is "false").

And sorry, did not get into fixing this yet. It is anyway on my long todo list. =)

blasrodri commented 5 years ago

Hi, I'm having the same problem. Could you perhaps be more specific on the hack? I haven't been able to implement it.

config.proxy.enabled = false # => all applications disabled
did not do the trick

Thanks for your support. And this is an awesome plugin.

codylane commented 5 years ago

I've also confirmed that I'm unable to disable the proxy configuration using the methods mentioned in this issue. It's been a few years since I wrote ruby but I'm going to take a stab a pull request to fix this behavior because I've lost some valuable time troubleshooting it.

codylane commented 5 years ago

Ok, so I think I've figured out how this all works finally and how to implement the feature to disable a configured proxy. This is currently under testing and I hope to have a PR ready to address in the new few days as I have spare time.

codylane commented 5 years ago

@vladonemo @blasrodri @AlexRadch - I believe I've addressed your concerns in the 2.0.0 release. Please confirm.

I'll close out this issue on Jan 11, 2019 if I don't hear from you guys by then. Thanks.

vladonemo commented 5 years ago

Just tested it and it works in our environment. By setting the proxy env. variables to empty before running vagrant up all the proxy settings are removed. The opposite use-case works, too.

Thanks a lot for addressing this 👍

codylane commented 5 years ago

Yay! I'm glad it worked and I'm happy to help. 👍