CentOS配置基於web認證的squid 3.1.23

來源:互聯網
上載者:User

CentOS配置基於web認證的squid 3.1.23

環境清單:

Centos 6.4 X64

Squid 3.1.23

Squid依然是當下流行的webProxy 伺服器軟體,它的發展曆史由來已久,當然,除了老牌之外,它其功能相當完善且幾乎完跨平台……今心血來潮,探索它auth模組中的Digest認證(squid支援的認證模組有好多,比如NCSA、LDAP、NTLM、PAM、SASL、Mysql、SMB、YP等,在此只研究Digest,其它後續)

一、平台就緒

1、 系統安裝

2、關閉iptables、Selinux

3、添加gcc、make、wget、perl等包

4、[root@vqiu] #useradd -M squid -s /sbin/nologin -c "Squid user" //添加squid使用者


二、安裝squid

[root@vqiu] # wget http://sourceforge.jp/projects/sfnet_brazilfw/downloads/3.x/source/pool/squid-3.1.23.tar.bz2
[root@vqiu] # tar xjf squid-3.1.23.tar.bz2
[root@vqiu]) # cd squid-3.1.23
[root@vqiu] # ./configure--prefix=/usr/local/squid \
--enable-async-io \
--enable-removal-policies=heap,lru \
--enable-default-err-languages="Simplify_Chinese"\
--enable-err-languages="Simplify_Chinese English"\
--enable-epoll \
--disable-http-violations \
--with-large-files \
--enable-auth="digest" \
--enable-digest-auth-helpers="password" \
--with-default-user=squid

[root@vqiu] # Make &&make install //中途沒有提示Error的話,說明已經安裝完成

三、配置squid

[root@vqiu] # chown squid/usr/local/squid –R

[root@vqiu] # Vi /usr/localhost/squid/etc/squid.conf//加入以下資訊:

//指定認證類型,-c選項將密碼進行加密儲存到指定檔案(/usr/local/squid/digest.passwd),不加選項則使用明文
auth_param digest program /usr/local/squid/libexec/digest_pw_auth -c /usr/local/squid/digest.passwd

//輔助進程數量,預設為5
auth_param digest children 8

//認證網域名稱稱
auth_param digest realm vqiu

//多久清空nonce緩衝,預設5分鐘
auth_param digest nonce_garbage_interval 5 minutes

//用戶端與squid保持nonce串連最長時效,超過後重新驗證
auth_param digest nonce_max_duration 30 minutes

//對nonce可使用50個請求
auth_param digest nonce_max_count 50

//定義一帳號多少個ip使用
acl FOO max_user_ip 1

//定義已認證的用戶端
acl know_cli proxy_auth REQUIRED

//允許存取max_user_ip
http_access allow FOO

//允許存取認證用戶端
http_access allow know_cli

//定義主機名稱,名稱可隨意
visible_hostname squid_server

四、 添加帳號

建立指令碼,內容如下:

#!/bin/bash
user=$1
pass=$2

realm=$3 //此選項必須與conf檔案中的auth_param digest realm XXX一致

if [ -z"$1" -o -z "$2" -o -z "$3" ] ; then
echo "Usage: $0 user password'realm'";
exit 1
fi
ha1=$(echo-n "$user:$realm:$pass"|md5sum |cut -f1 -d' ')
echo"$user:$realm:$ha1" >>/usr/local/squid/digest.passwd

建立使用者格式:sh shell_script username password realm(本例為vqiu)

例:添加一個使用者名稱與密碼為test的使用者---sh script_name vqiu vqiu

五、 啟動squid 服務

將/usr/local/squid/bin與sbin這兩目錄加入PATH變數中

[root@vqiu]# squid –k check或squid –k parse //排錯squid設定檔

[root@vqiu]# Squid –zX //初始化squid

[root@vqiu]# squid –s //後台啟動服務

服務啟動成功

六、 配置用戶端

進入internet explorer選項,設定proxy。

輸入網址,將彈出以下視窗,把已添加的使用者填上。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.