Vagrant Proxy Configuration Plugin

Gem Version Build Status Dependency Status Code Climate

A Vagrant plugin that configures the virtual machine to use specified proxies for package managers etc.

At this state we support:

  • APT proxy/cacher

Support is planned for other package managers (at least yum).

Installation

Note: This plugin requires Vagrant v1.2 or newer (downloads).

Install using standard Vagrant plugin installation method:

vagrant plugin install vagrant-proxyconf

Usage

Proxy settings can be configured in Vagrantfile. In the common case that you want to use the same configuration in all Vagrant machines, you can use $HOME/.vagrant.d/Vagrantfile or environment variables. Package manager specific settings are only used on supporting platforms (i.e. Apt configuration on Debian based systems), so there is no harm using global configuration.

Project specific Vagrantfile overrides global settings. Environment variables override both.

Apt

Configures Apt to use the specified proxy settings. The configuration will be written to /etc/apt/apt.conf.d/01proxy on the guest.

Example Vagrantfile

Vagrant.configure("2") do |config|
  config.apt_proxy.http  = "192.168.33.1:3142"
  config.apt_proxy.https = "DIRECT"
  # ... other stuff
end

Configuration keys

  • config.apt_proxy.http - The proxy for HTTP URIs
  • config.apt_proxy.https - The proxy for HTTPS URIs
  • config.apt_proxy.ftp - The proxy for FTP URIs

Possible values

  • If all keys are unset or nil, no configuration is written.
  • A proxy can be specified in the form of [http://][user:pass@]host[:port]. So all but the host part are optional. The default port is 3142 and protocol is the same as the key.
  • Empty string ("") or false in any protocol also force the configuration file to be written, but without configuration for that protocol. Can be used to clear the old configuration and/or override a global setting.
  • "DIRECT" can be used to specify that no proxy should be used. This is mostly useful for disabling proxy for HTTPS URIs when HTTP proxy is set (as Apt defaults to the latter).
  • Please refer to apt.conf(5) manual for more information.

Environment variables

  • APT_PROXY_HTTP
  • APT_PROXY_HTTPS
  • APT_PROXY_FTP

These also override the Vagrantfile configuration. To disable or remove the proxy use "DIRECT" or an empty value.

For example to spin up a VM, run:

APT_PROXY_HTTP="proxy.example.com:8080" vagrant up

Running apt-cacher-ng on a Vagrant box

Here is an example for setting up apt-cacher proxy server in a Vagrant VM.

  • apt-cacher-box
    a Vagrant setup for apt-cacher-ng.
  • vagrant-cachier
    An excellent Vagrant plugin that shares various cache directories among similar VM instances. Should work fine together with vagrant-proxyconf.
  • vagrant-httpproxy
    A Chef cookbook for configuring Chef resources to use the specified proxy (while offline).
  • vagrant-proxy
    A Vagrant plugin that uses iptables rules to force the VM to use a proxy.