0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ubuntu (debian系も?)にapt キャッシュサーバー機能を付けて転送を効率よくする(https問題も記述)

Last updated at Posted at 2021-02-24

Ubuntu ( debian 系も?) に apt キャッシュサーバー機能を付けて転送を効率よくします。

下記コマンドでメインの PC に apt のキャッシュサーバー機能をインストールします。

sudo apt-get update; sudo apt-get install apt-cacher-ng ; echo 'Acquire::http::Proxy "http://127.0.0.1:3142";' | sudo tee /etc/apt/apt.conf.d/02proxy ;

次にサブ機で apt update する場合はキャッシュを見るように設定を行います。

sudo gedit /etc/apt/apt.conf.d/02proxy ;

192.168.0.xxx の部分はメインPCのIPアドレスを入力します。IPアドレスの確認は ifconfig コマンドで行えます。

/etc/apt/apt.conf.d/02proxy
Acquire::http::Proxy "http://192.168.0.xxx:3142";

これで、メイン機、サブ機ともに 192.168.0.xxx からキャッシュを読み込むようになります。

ちなみにたまにレポジトリが http ではなく https でエラーが出る場合は下記のようにキャッシュは使わず直接読みに行くようにします。

sudo gedit /etc/apt-cacher-ng/acng.conf ;
/etc/apt-cacher-ng/acng.conf
PassThroughPattern: .*

あとはサービスを再起動して設定を再読込させます。

sudo service apt-cacher-ng restart

マシンが増える場合はもちろんのこと、なるべく転送量を抑えたい IOT 系 SIM 向けに事前にキャッシュを作っておくと転送料金を気にしなくて良いかと思います。

参考リンク

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?