Ruby gem的proxy代理設定方法

來源:互聯網
上載者:User

        公司裡上網是通過公司自己做的代理,因此使用Rubygem的時候沒有辦法直接安裝我們需要的包如Rails,在網上查了很多的有關gem使用代理的方法,很多人都寫到gem支援-p參數來設定代理,但是我試了很久沒有成功。 現在把我設定成功的方法記下來,以免以後忘掉:

        在windows裡有兩種,第一種是使用代理軟體,這個我就不說了,自己看著辦吧;
        第二種,在命令列下輸入:set http_proxy=url,後面的url是你的Proxy 位址,如:http://192.168.0.1:8081什麼的。設定完後就可以直接使用gem命令了。

下面是官方的原文:

Running gem install when you are behind a proxy.

Set the HTTP_PROXY environment variable.

Note this is fully qualified, as such:
http_proxy=http://URL:PORT

http_proxy=http://127.0.0.1:5865
in this example, the proxy is running on the localhost. With NTLM authorization to get through a corporate firewall.

NB: This may not work if you are behind a Microsoft ISA Proxy server with only NTLM (MS ISA Server proprietary) authentication available. If this is the case, you can try the Microsoft Firewall Client or the Python NTLM Authorization Proxy Server.

JB: A gem is available which gives ruby the ability to authenticate with ISA natively. To use it with gems follow these steps:

  1. Download rubysspi from the Ruby Win32 SSPI project page(also available as gem install rubysspi but that doesn’t help much, does it?)
  2. Install the gem locally
  3. Copy spa.rb from the gem install to your site-ruby directory
  4. Find gem.cmd in your ruby bin directory and add ”-rspa” to the command line.
  5. Set http_proxy environment variable as above
  6. gem list rails

希望這些能對大家有用!!!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.