Vagrantで作成した仮想マシンのプロキシを設定する
Vagrant で作成した仮想マシンをプロキシ環境下で使用するには、vagrant-proxyconf プラグインを使って設定します。
vagrant-proxyconf によるプロキシ設定
次のコマンドで vagrant-proxyconf プラグインをインストールします。
$ vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
Installed the plugin 'vagrant-proxyconf (1.5.2)'!
次に、Vagrantfile へプロキシ設定を追加します。
Vagrant.configure(2) do |config|
if Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = "http://{アドレス}:{ポート}"
config.proxy.https = "http://{アドレス}:{ポート}"
config.proxy.no_proxy = "127.0.0.1,localhost"
end
end
以上の設定で、Vagrant 仮想マシンを立ち上げるときにプロキシが設定されます。
Vagrantfileの変更を反映させる
Vagrantfile の内容を書き換えたあと、その内容を反映させるには Vagrantfile のあるディレクトリで次のコマンドを実行します。
$ vagrant reload