2012-07-18 230 views
17

後使用CPAN代理服務器失敗我在企業環境中有一個Linux機器,通過需要身份驗證的代理來訪問網絡。在初始化/代理服務器/代理服務器/

在CPAN它自動的第一次運行配置的一切,它一般不會:

Autoconfigured everything but 'urllist'. Please call 'o conf init urllist' to configure your CPAN server(s) now!

commit: wrote '/usr/lib/perl5/5.10.0/CPAN/Config.pm'

知道我有一個代理服務器瀏覽,並具有閱讀有關代理和CPAN在網絡上的文檔和幾頁我:

cpan[1]> o conf init /proxy/

If you're accessing the net via proxies, you can specify them in the CPAN configuration or via environment variables. The variable in the $CPAN::Config takes precedence.

Your ftp_proxy? []

Your http_proxy? [] 10.12.8.9:3128

Your no_proxy? []

If your proxy is an authenticating proxy, you can store your username permanently. If you do not want that, just press RETURN. You will then be asked for your username in every future session.

Your proxy user id? [] my_net_id

Your password for the authenticating proxy can also be stored permanently on disk. If this violates your security policy, just press RETURN. You will then be asked for the password in every future session.

CPAN: Term::ReadKey loaded ok (v2.30) Your proxy password? Please remember to call 'o conf commit' to make the config permanent!

cpan[2]> o conf commit commit: wrote '/usr/lib/perl5/5.10.0/CPAN/Config.pm'

現在都應該好了吧? 所以我希望,

cpan[3]> i /Some::Module/ CPAN: Storable loaded ok (v2.18)

I would like to connect to one of the following sites to get 'authors/01mailrc.txt.gz':

http://www.perl.org/CPAN/ ftp://ftp.perl.org/pub/CPAN/

Is it OK to try to connect to the Internet? [yes] LWP not available

Trying with "/usr/bin/curl -L -f -s -S --netrc-optional" to get http://www.perl.org/CPAN/authors/01mailrc.txt.gz curl: (22) The requested URL returned error: 407

System call "/usr/bin/curl -L -f -s -S --netrc-optional " http://www.perl.org/CPAN/authors/01mailrc.txt.gz " > /root/.cpan/sources/authors/01mailrc.txt.tmp29726" returned status 22 (wstat 5632) Warning: expected file [/root/.cpan/sources/authors/01mailrc.txt.gz.tmp29726] doesn't exist

Trying with "/usr/bin/wget -O /root/.cpan/sources/authors/01mailrc.txt.tmp29726" to get http://www.perl.org/CPAN/authors/01mailrc.txt.gz --2012-07-17 15:57:38-- http://www.perl.org/CPAN/authors/01mailrc.txt.gz Connecting to 10.12.8.9:3128... connected. Proxy request sent, awaiting response... 301 Moved Permanently Location: http://www.cpan.org/authors/01mailrc.txt.gz [following] --2012-07-17 15:57:38-- http://www.cpan.org/authors/01mailrc.txt.gz Connecting to 10.12.8.9:3128... connected. Proxy request sent, awaiting response... 407 Proxy Authentication Required 2012-07-17 15:57:38 ERROR 407: Proxy Authentication Required.

那麼密碼提示哪裏?

我錯過了什麼配置cpan通過身份驗證企業代理訪問互聯網?

回答

9

安裝LWP。 cpan實用程序使用curl,我猜是因爲它無法加載LWP。沒有代理參數被傳遞給curl,因此在運行命令之前需要導出http_proxy = http:// host:port /。

或者,如果您可以使用發行版的軟件包管理器安裝LWP,那麼它應該正確配置代理訪問。

+0

我們有一個贏家。雖然看起來像把馬車放在馬前,但可以手動安裝LWP及其18個依賴項,然後cpan將通過代理進行導航。 @盧西亞諾有它。 – MichaelRpdx 2012-07-18 17:44:29

+0

作爲從CPAN手動安裝19個軟件包的替代方法,可以嘗試'o conf'將'http_proxy','proxy_user'和'proxy_pass'的所有三個設置爲空字符串(或者從〜/ .cpan/CPAN中刪除它們/ MyConfig.pm'文本編輯器)。然後確保在您的shell環境中設置了'HTTP_PROXY','HTTPS_PROXY'和小寫變體。 _這對我來說是一個全新的來自源代碼的Perl安裝和一個需要身份驗證的公司HTTP代理._ – TheDudeAbides 2017-10-21 01:43:28

3

你可以嘗試調用cpan前使用此:

export http_proxy=http://my_net_id:[email protected]:3128/ 

這樣也許curl將使用代理。

+0

事實上,輸入'10.12.8.9:3128'看起來是錯誤的。它應該說'http://10.12.8.9:3128'。 – daxim 2012-07-18 15:21:55

+0

@Paulo這沒有效果 – MichaelRpdx 2012-07-18 15:48:14

+0

@daxim從我發佈的日誌中注意到cpan連接到代理服務器,它只是沒有做所需的驗證 – MichaelRpdx 2012-07-18 15:50:58

22

您需要提供絕對代理URL地址來配置CPAN代理設置。請不要擔心,只需提供如下所示的IP地址和端口號。

cpan> o conf init /proxy/ 

Your ftp_proxy? [] ftp://10.12.8.9:3128 

Your http_proxy? [] http://10.12.8.9:3128 

Your no_proxy? [] 

,並提供用戶名密碼如果需要的話(請確保您有下載權限)

我也有同樣的問題,但現在它爲我工作。我也應該爲你工作。

BR 傑裏詹姆斯

+0

這是我刪除代理的正確答案。 現有的docker鏡像/容器有一個http_proxy的環境,我想解除它。 – 2016-06-08 05:17:02