Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

Wget,cURLにおいてProxyを利用する際の設定

More than 3 years have passed since last update.

cURL

$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
curl: (7) couldn't connect to host
  • -xを使う
 -x/--proxy <host[:port]> Use HTTP proxy on given port
    --proxy-anyauth Pick "any" proxy authentication method (H)
    --proxy-basic   Use Basic authentication on the proxy (H)
    --proxy-digest  Use Digest authentication on the proxy (H)
    --proxy-negotiate Use Negotiate authentication on the proxy (H)
    --proxy-ntlm    Use NTLM authentication on the proxy (H)
$ curl -x http://192.***.***.***:****/ https://bootstrap.pypa.io/get-pip.py -o get-
pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1488k  100 1488k    0     0  3381k      0 --:--:-- --:--:-- --:--:-- 5816k

Wget

$ wget --no-check-certificate https://access.redhat.com
--2016-07-15 19:13:54--  https://access.redhat.com/
access.redhat.com をDNSに問いあわせています... ***.***.***.***
access.redhat.com|***.***.***.***|:443 に接続しています... 失敗しました: 接続がタイムアウトしました.
  • /etc/wgetrcに明示的に有効と記述する
--- /etc/wgetrc.orig    2016-07-15 19:11:40.368050104 +0900
+++ /etc/wgetrc 2016-07-15 19:16:53.756649933 +0900
@@ -77,9 +77,11 @@
 # They will override the value in the environment.
 #https_proxy = http://proxy.yoyodyne.com:18023/
 #http_proxy = http://proxy.yoyodyne.com:18023/
+http_proxy = http://192.***.***.***:****/
+https_proxy = http://192.***.***.***:****/
 #ftp_proxy = http://proxy.yoyodyne.com:18023/
 # If you do not want to use proxy at all, set this to off.
-#use_proxy = on
+use_proxy = on

 # You can customize the retrieval outlook.  Valid options are default,
 # binary, mega and micro.
$ wget --no-check-certificate https://access.redhat.com
--2016-07-15 19:19:14--  https://access.redhat.com/
192.***.***.***:****/ に接続しています... 接続しました。
Proxy による接続要求を送信しました、応答を待っています... 200 OK
長さ: 89324 (87K) [text/html]
`index.html' に保存中

100%[===============================================================>] 89,324      --.-K/s 時間 0.07s   

2016-07-15 19:19:15 (1.29 MB/s) - `index.html' へ保存完了 [89324/89324]

環境変数

  • 登録
$ export http_proxy=http://192.***.***.***:****/
$ export https_proxy=http://192.***.***.***:****/
  • 削除
$ unset http_proxy
$ unset https_proxy
ldr
https://tech.enechange.co.jp/ ENECHANGEの中の人です。内容が重複している場合があります。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away