tmatilai / vagrant-proxyconf

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

Add support for processing of .pac files #46

Closed imavroukakis closed 3 years ago

imavroukakis commented 10 years ago

Support for proxy auto-configuration files would be highly useful. The PAC file is well documented ( several references in http://en.wikipedia.org/wiki/Proxy_auto-config ) but in a nutshell what would be required is for Ruby code to be able to execute Javascript. A possible candidate would be execjs -> http://rubygems.org/gems/execjs

johnbellone commented 10 years ago

We use this here for wpad proxies. It would require embedding v8 or some JavaScript interpreter and then taking the results and applying accordingly.

tmatilai commented 10 years ago

Thanks!

Unfortunately I can see some challenges here. The PAC file works by querying proxy configs by hostname. But we can only use http_proxy for setting one proxy, and no_proxy for a list of globs for direct access. So we can try to get out the default proxy config using some weird URL/hostname, but I can't think of nothing more.

Does anyone have more ideas how to implement this?

imavroukakis commented 10 years ago

Hence execjs :smile:

imavroukakis commented 10 years ago

I don't think that would be an issue. You can try to ask for google.com by default or it can be a configurable option if for some reason google is blocked in certain restrictive environments/countries :smiling_imp: .

tmatilai commented 10 years ago

But there's no way to build no_proxy.

Especially if the PAC URL has to be configured based on your location, and all we get from there is the default proxy URL, isn't it the same to configure just that one proxy URL directly? WPAD then requires more logic for finding the PAC in the first place. A quick search didn't show any wpad libraries.

Somehow it feels like a lot of work for the benefits. So I'm not sure I feel like implementing this myself (as I don't even have use for it myself). But of course I'm open for pull requests. ;)

imavroukakis commented 10 years ago

Well not necessarily. For example in my organisation, we have offices spread all over the globe. So the PAC file, resolves for different proxies according to the network you are in (and it's a massive file for obvious reasons). I would argue against the need for WPAD to be honest, support for PAC gives more bang for your buck!

tmatilai commented 10 years ago

@imavroukakis gotcha, if you think it will be enough for you then I'm fine. =) But don't you need to set env vars on your host for all of the other software too? Or do you work only in the VMs?

imavroukakis commented 10 years ago

I do, but the VM's don't (can't) use that.

tmatilai commented 10 years ago

Getting OT here (no prob), but if you have the proxy on HTTP_PROXY etc. vars on the host, you can just pass those to proxyconf in Vagrantfile.

config.proxy.http = ENV.fetch('HTTP_PROXY', false)
# ...

Hmm, this would be an useful example in the documentation...

imavroukakis commented 10 years ago

you could, but not in the instances where you are using a PAC. Also, it's a little opaque as to what the behaviour of proxyconf is when the env simply does not exist.

otahi commented 10 years ago

Hi, @imavroukakis

I have developed the gem pacproxy which can provide a proxy server configured with a proxy.pac file. Can you try it?

MatheusWebDev commented 3 years ago

Hi, something was done or thinking about this issue ? In my company the proxy uses the .pac file to config and a can't use vagrant, because don't recognize it.

codylane commented 3 years ago

This is not a supported feature as it stands today and one I think would be better served by an additional library. Perhaps, you can download your pac file and configure your global Vagrantfile to use the right settings? Last time I used a pac file it was a straight text file that I could browse with any standard editor.