[AWS] Amazon Linux 2において、yum, amazon-linux-extras, curlにプロキシサーバー設定

AWSのプライベートサブネット内のEC2インスタンス(ami=Amazon Linux 2)において、yum, amazon-linux-extras, curlコマンドを使用する際に、パブリックサブネット内のEC2インスタンスをプロキシサーバーとして設定する方法についてメモる。

ここでは、プロキシサーバーのURLは、http://10.0.1.108:3128とする。

yum

/etc/yum.cof の末尾に、proxy=http://10.0.1.108:3128を追加する。

echo proxy=http://10.0.1.108:3128 | sudo tee -a /etc/yum.conf

ちなみに、man yum.conf コマンドで、「proxy」を検索すると、以下のように記述されている。

proxy URL to the proxy server that yum should use.  Set this  to `libproxy’  to  enable  proxy  auto  configuration via libproxy. Defaults to direct connection.

man yum.conf

amazon-linux-extras

/etc/amazon-linux-extras.conf を作成して、以下を記述。

export http_proxy=http://10.0.1.108:3128
export https_proxy=http://10.0.1.108:3128

curl

curlコマンドのオプションとして、–proxy, -xを使用する。

curl -x http://10.0.1.108:3128 http://abehiroshi.la.coocan.jp/top.htm

参考

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です