LoginSignup
135
156

More than 3 years have passed since last update.

proxy環境下の設定(ubuntu 14.04)

Last updated at Posted at 2016-01-17

職場等のproxy環境下で、gitやwget等のコマンドはProxyサーバーを指定しなければ使用できません。
多くのProxy環境は、ユーザー認証付きだと思われるので、全て認証つきの設定を紹介してみます。
(残念ですが、Proxyサーバーの構築方法ではありません。)
確認したOSは、ubuntu 14.04です。

環境変数の設定

とりあえず、export設定。
.bashrcや、.bash_profileに設定することも可なので、使用頻度や、環境に合わせて設定してもよいと思います。
とりあえずこの設定で大部分はまかなえるかと思います。

$ export https_proxy="http://username:password@your.proxy.address:proxy.port/"
$ export http_proxy="http://username:password@your.proxy.address:proxy.port/"
$ export ftp_proxy="http://username:password@your.proxy.address:proxy.port/"

sudo

sudoは一般の環境変数を引き継がないので、configファイルに設定している、http-proxyなどは無視される傾向にあります。
以下のように、-E を付加すれば、環境変数が引き継ぐ事ができます。

$ sudo -E apt-add-repository ppa:.....
$ sudo -E apt-get update
$ sudo -E apt-get install subversion

apt-getの場合

環境変数(http_proxy,ftp_proxy等)に設定する方法と、/etc/apt/apt.confに設定する方法の2パターンがあります。
両方に設定されている場合は、apt.confのものが有効になるようです。

環境変数の設定を行う場合は、前述の記載を参照。
/etc/apt/apt.confに設定する場合は、apt.confに以下の行を追加します。

Acquire::ftp::proxy "ftp://username:password@your.proxy.address:proxy.port/";
Acquire::http::proxy "http://username:password@your.proxy.address:proxy.port/";
Acquire::https::proxy "https://username:password@your.proxy.address:proxy.port/";

wgetの場合

/etc/wgetrc を編集します。

https_proxy = http://username:password@your.proxy.address:proxy.port/
http_proxy = http://username:password@your.proxy.address:proxy.port/
ftp_proxy = http://username:password@your.proxy.address:proxy.port/

gitの場合

~/.gitconfig ファイルのhttpの項目に次の設定を追加します。

[http]
proxy = http://username:password@your.proxy.address:proxy.port/

config コマンドで次のように設定することもできます。

$ git config --global http.proxy http://username:password@your.proxy.address:proxy.port/

npmの場合

以下のコマンドで、npmのconfigファイルを設定します。

$ npm config set proxy http://username:password@your.proxy.address:proxy.port/
$ npm config set https-proxy http://username:password@your.proxy.address:proxy.port/

SVNの場合

~/.subversion/servers ファイルの[global] httpの項目に次の設定を追加します。

[global]
http-proxy-host = host ip address
http-proxy-port = port number
http-proxy-username = defaultusername
http-proxy-password = defaultpassword

gsutil(Google Cloud(Boto))の場合

Google Cloud Storageを使用するためのユーティリティ、”gsutil”を使用する場合に必要となる設定です。

設定に必要な、"~/.boto"ファイルは、以下のようにconfig を実行することによって、作成されるファイルです。

$ gsutil config

~/.boto ファイルのhttpの項目に次の設定を追加します。

[Boto]
proxy = <ip address>
proxy_port = <port>
proxy_user = <your proxy user name>
proxy_pass = <your proxy password>

gemの場合

環境変数の設定を行っていれば、実行可能だと思いますが、それでもダメな時は、gem installコマンドと同時にProxy環境を指定します。

$ gem install パッケージ名 -r -p http://username:password@your.proxy.address:proxy.port/

gradleの場合

専用のプロパティファイルに設定します。プロパティファイルは、"~/.gradle/gradle.properties" ファイルです。
このファイルは、インストール後に自動的に生成されていないので、新規作成する必要があります。
各Proxyは以下のように設定します。(詳細は公式サイトを参照願います)

systemProp.http.proxyHost=your.proxy.address
systemProp.http.proxyPort=proxy.port
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.https.proxyHost=your.proxy.address
systemProp.https.proxyPort=proxy.port
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password

curlの場合

~/.curlrc ファイルに次の設定を追加します。

proxy-user = "username:password"
proxy = "http://your.proxy.address:proxy.port"

ここまではubuntu 14.04の設定方法でしたが、Mac OS Xでもほぼ同様です。
ただし、ユーザー認証付きProxy環境下では、アプリをApp StoreへSubmitはできませんでした…

135
156
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
135
156