LoginSignup
14
16

More than 5 years have passed since last update.

JavaエンジニアがUbuntuで設定すべきプロキシ設定まとめ

Last updated at Posted at 2015-02-05

環境変数+Gradle

/etc/environment を以下のように編集する。
各ユーザ毎に正しい場所に設定したいのであれば、最初に提示したマニュアルを参照のこと。

http_proxy=http://example.jp:8080
https_proxy=http://example.jp:8080
GRADLE_OPTS=" -Dhttp.proxyHost=example.jp -Dhttp.proxyPort=8080 -Dhttps.proxyHost=example.jp -Dhttps.proxyPort=8080"

sodoコマンド経由で何かを実行している時にプロキシの設定がきいてない場合には、
sudo -Eすると環境変数が引き継がれるのでうまく動くかもしれない。

APT

/etc/apt/apt.confを以下のように編集する。

Acquire::http::proxy "http://example.jp:8080";
Acquire::https::proxy "http://example.jp:8080";

git

以下のコマンドを実行する。

git config --global http.proxy http://example.jp:8080
git config --global https.proxy http://example.jp:8080

~/.gitconfigを以下のように編集してもよい。

[http]
        proxy = http://example.jp:8080
[https]
        proxy = http://example.jp:8080

Maven

~/.m2/settings.xmlを以下のように編集する。ファイルが当該個所に無ければ作る。

<settings>
 <proxies>
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>example.jp</host>
      <port>8080</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    <proxy>
      <id>optional2</id>
      <active>true</active>
      <protocol>https</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>example.jp</host>
      <port>8080</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
  </proxies>
</settings>
14
16
0

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
14
16