■ 準備
htpasswdコマンドを使う設定を行う
Basic認証の場合、パスワードファイルはハッシュ化する必要があるためsudo yum -y install httpd-toolshttp://tanihiro.hatenablog.com/entry/2014/02/05/172938
■ 構築手順
* Basic認証のための設定を行う
[1] 設定ファイル「squid.conf」を修正する
sudo vi /etc/squid/squid.conf ~~~~ acl CONNECT method CONNECT auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/.htpasswd auth_param basic children 5 auth_param basic realm Squid Basic Authentication auth_param basic credentialsttl 5 hours acl password proxy_auth REQUIRED http_access allow password ~~~~設定の説明は、以下のサイトを参照
http://www.satlab-gineiden.com/pc-soft/proxy_server.html/2
[2] Basic認証用のパスワードファイル「.htpasswd」を作成
sudo htpasswd -c /etc/squid/.htpasswd 【ユーザ名】# 新規作成 sudo htpasswd -c /etc/squid/.htpasswd admin New password: 【パスワードを入力(例:「password」)】 Re-type new password: 【パスワードを入力(例:「password」)】 Adding password for user admin # ユーザー追加 sudo htpasswd -b /etc/squid/.htpasswd guest password # ユーザー削除 sudo htpasswd -D /etc/squid/.htpasswd guest
[3] Squid を再起動する
# 再起動 sudo systemctl restart squid # 「active (running) 」であることを確認 sudo systemctl status squid
[4] 動作確認
* Firefoxなどのブラウザで「yahoo.co.jp」をアクセスする => ダイアログ表示「・・・"Squid Basic Authentication"・・・」が表示されるはず。 => 以下を入力する + ユーザ名 :【[2] で設定したユーザ名を入力(例:「admin」)】 + パスワード:【[2] で設定したパスワードを入力(例:「password」)】
参考文献
http://skkskynw.hateblo.jp/entry/2016/09/04/163713https://www.server-world.info/query?os=CentOS_7&p=squid&f=3
http://kimagureneet.hatenablog.com/entry/2017/02/02/115212