LoginSignup
5

More than 3 years have passed since last update.

Raspbianプロキシ設定まとめ

Raspbian Busterでプロキシをもろもろ設定したのでまとめます。

apt-get

export http_proxy="http://USERNAME:PASSWORD@IP:PORT/"
export https_proxy="http://USERNAME:PASSWORD@IP:PORT/"
export ftp_proxy="http://USERNAME:PASSWORD@IP:PORT/"

時刻

プロキシ経由だとntpが効かない。
次のコマンドの後rebootで時刻を合わせる。

date --set @"$(wget -q https://ntp-a1.nict.go.jp/cgi-bin/jst -O - | sed -n 4p | cut -d. -f1)"

chromium

オプションをつけて起動かプラグインを入れるか。
プラグインを入れると通常起動でプロキシが使える。
下記コマンドでchromiumを起動して、Chromeウェブストアからプラグイン「Proxy SwitchyOmega」を追加する。

chromium-browser --proxy-server=https=IP:PORT

追加できたら次のように設定し「Apply change」を押す。
※時刻が合ってないとプラグインの追加ができないっぽい
image.png

wget

/etc/wgetrcYou can set the default proxies...のところに追記

/etc/wgetrc
http_proxy="http://USERNAME:PASSWORD@IP:PORT/"
https_proxy="http://USERNAME:PASSWORD@IP:PORT/"
ftp_proxy="http://USERNAME:PASSWORD@IP:PORT/"

git

git config --global http.proxy http://IP:PORT
git config --global https.proxy http://IP:PORT

python

pythonのリクエストモジュールは大文字の指定しか読み込まないらしい。

export HTTP_PROXY="http://USERNAME:PASSWORD@IP:PORT/"
export HTTPS_PROXY="http://USERNAME:PASSWORD@IP:PORT/"
export FTP_PROXY="http://USERNAME:PASSWORD@IP:PORT/"

pip instal

pipはオプションにつけるしかない

pip install もじゅーる --proxy="http://USERNAME:PASSWORD@IP:PORT/"

SSL認証系のエラーが置きたら以下のオプションを追加するといい

 --trusted-host pypi.org --trusted-host www.piwheels.org

curl

-x で指定

curl ~~ -x http://IP:PORT

Docker

daemon

sudo mkdir -p /etc/systemd/system/docker.service.d
echo -e "[Service]\nEnvironment=\"HTTP_PROXY=http://IP:PORT\"" | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf
sudo systemctl daemon-reload
sudo systemctl restart docker

container

mkdir ~/.docker
nano ~/.docker/config.json
{
    "proxies":
    {
        "default":
        {
            "httpProxy": "http://IP:PORT"
        }
    }
}

npm

sudo npm -g config set proxy "http://USERNAME:PASSWORD@IP:PORT/"
sudo npm -g config set https-proxy "http://USERNAME:PASSWORD@IP:PORT/"
sudo npm -g config set registry "http://registry.npmjs.org/"

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
What you can do with signing up
5