How to use vagrant in a proxy environment?

前端 未结 12 906
太阳男子
太阳男子 2020-12-07 08:10

My company\'s network is using proxy. So when I use vagrant up, it showed me a 401 permission error.

How can I do some setting to use vagrant?

12条回答
  •  [愿得一人]
    2020-12-07 08:36

    If your proxy requires authentication it is better to set the environment variable rather than storing your password in the Vagrantfile. Also your Vagrantfile can be used by others easily who are not behind a proxy.

    For Mac/Linux (in Bash)

    export http_proxy="http://user:password@host:port"
    export https_proxy="http://user:password@host:port"
    vagrant plugin install vagrant-proxyconf
    

    then

    export VAGRANT_HTTP_PROXY=${http_proxy}
    export VAGRANT_HTTPS_PROXY=${https_proxy}
    export VAGRANT_NO_PROXY="127.0.0.1"
    vagrant up
    

    For Windows use set instead of export.

    set http_proxy=http://user:password@host:port
    set https_proxy=https://user:password@host:port
    vagrant plugin install vagrant-proxyconf
    

    then

    set VAGRANT_HTTP_PROXY=%http_proxy%
    set VAGRANT_HTTPS_PROXY=%https_proxy%
    set VAGRANT_NO_PROXY="127.0.0.1"
    vagrant up
    

提交回复
热议问题