-
Notifications
You must be signed in to change notification settings - Fork 73
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 proxy listening on localhost on the host #82
Comments
Hi, @copumpkin . I am afraid that I do not understand what your issue is. If your issue is only to access proxy on the host, If you want a simple solution to use a proxy on the host like as followings, it will need development.
or
Which is your issue? Or your have another issue? |
Hi @copumpkin, @otahi , I also have this issue. In my work environment I need to use cntlm to effectively go around the corporate proxy (requires authentication). Storing my personal credentials in the (eventually checked-in) Vagrantfile is a deal breaker, so I'm looking for alternatives. For me personally the second option would be the best (using $vagrant_host), since it seems like the most straightforward to read and understand what exactly is being configured. |
@ruipires a common way to handle secrets is to use environment variables and access them in Vagrantfile like: config.proxy.http = "http://#{ENV['PROXY_CREDENTIALS']}@proxy.example.com:3128` Often you also want configure the proxy for all VMs in ~/.vagrant.d/Vagrantfile instead of project specific Vagrantfiles. But I still understand that this feature would be useful. Unfortunately I don't know any reliable way to know the host IP as it's very provider specific. A hack to try could be to ssh into the VM and try to figure out the source IP for that connection. This would still require that the proxy on the host is accessible from that interface (no way to access the host's loopback directly from the VM). Sorry, but I can't promise that I'll work on this in the near future. As always, I'm happy to review pull requests though. =) |
I'm still getting used to vagrant, so no pull requests in the near future from me ;) |
I want to try this impl, when I have time. @tmatilai says:
I think so too`. But we can get the default gateway or some specific IP addresses. I welcome not only pull requests but also ideas like this 😄 |
One workaround is to simply let your local proxy also listen on the virtual network, be it virtualbox, libvirt/kvm, lxc or docker (worked for me with all). E.g. snippet from
Then instead of pointing to 127.0.0.1, use the proxy interface on the host for bridge/nat network created for the VM guests., e.g. 192.168.56.1. That works from both the host and the guest VMs. I'm not sure it's reasonable to expect the plugin dev to try manage this complexity. |
I have a proxy listening on localhost on my Vagrant host. The issue is that localhost becomes 10.0.2.2 from the guest's perspective. When I log into my guest, the http_proxy variables are set to "localhost", which thus point to the guest and don't work.
I imagine we'd just need some special logic that looks for localhost/127.0.0.1 and rewrites it to the host IP when setting the variables in the guest.
The text was updated successfully, but these errors were encountered: