设为首页 收藏本站
查看: 1676|回复: 0

[经验分享] CentOS配置基于web认证的squid 3.1.23

[复制链接]
累计签到:1365 天
连续签到:1 天
发表于 2015-11-19 11:07:58 | 显示全部楼层 |阅读模式
环境清单:
         Centos 6.4 X64
         Squid 3.1.23
      Squid依然是当下流行的web代理服务器软件,它的发展历史由来已久,当然,除了老牌之外,它其功能相当完善且几乎完跨平台……今心血来潮,探索它auth 模块中的Digest认证(squid支持的认证模块有好多,比如NCSALDAPNTLMPAMSASLMysqlSMBYP等,在此只研究Digest,其它后续)
DSC0000.jpg

一、 平台就绪
1、  系统安装
2、  关闭iptablesSelinux

3、  添加 gccmakewgetperl等包

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


二、 安装squid
[iyunv@vqiu] # wget http://sourceforge.jp/projects/sfnet_brazilfw/downloads/3.x/source/pool/squid-3.1.23.tar.bz2
[iyunv@vqiu] # tar xjf squid-3.1.23.tar.bz2
[iyunv@vqiu]) # cd squid-3.1.23
[iyunv@vqiu] # ./configure --prefix=/usr/local/squid \
--enable-async-io \

[size=1em]--enable-removal-policies=heap,lru \
[size=1em]--enable-default-err-languages="Simplify_Chinese"\
[size=1em]--enable-err-languages="Simplify_Chinese English"\
[size=1em]--enable-epoll \
[size=1em]--disable-http-violations \
[size=1em]--with-large-files \
[size=1em]--enable-auth="digest" \
[size=1em]--enable-digest-auth-helpers="password" \
[size=1em]--with-default-user=squid

[iyunv@vqiu] [size=1em]  # Make &&make install //[size=1em]中途没有提示[size=1em]Error[size=1em]的话,说明已经安装完成

三、 配置squid
[iyunv@vqiu] # chown squid/usr/local/squid –R

[iyunv@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
[size=1em]user=$1
[size=1em]pass=$2

[size=1em]realm=$3  [size=1em]  //[size=1em]此选项必须与[size=1em]conf[size=1em]文件中的[size=1em] auth_paramdigest realm XXX    [size=1em]一致[size=1em]

if [ -z"$1" -o -z "$2" -o -z "$3" ] ; then
[size=1em]        echo "Usage: $0 user password'realm'";
[size=1em]        exit 1
[size=1em]fi
[size=1em]ha1=$(echo-n "$user:$realm:$pass"|md5sum |cut -f1 -d' ')
[size=1em]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/binsbin 这两目录加入PATH变量中
[iyunv@vqiu] # squid –k check squid–k parse                    //排错squid配置文件
[iyunv@vqiu] # Squid –zX                                                         //初始化squid
[iyunv@vqiu] # squid –s                                                           //后台启动服务

DSC0001.png
服务启动成功

六、 配置客户端
进入internet explorer 选项,设置 proxy


DSC0002.png

输入网址,将弹出以下窗口,把已添加的用户填上。

DSC0003.png






Set Basic Authentication and limit squid for users to require authentication.[1]Install a package which includes htpasswd.[iyunv@prox ~]# yum -y install httpd-tools[2]Configure Squid to set Basic Auth.[iyunv@prox ~]# vi /etc/squid/squid.confacl CONNECT method CONNECT
# line 26: add follows for Basic Auth
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# add a user : create a new file with "-c" ( add the "-c" option only for the initial registration )
[iyunv@prox ~]# htpasswd -c /etc/squid/.htpasswd cent
New password: # set password
Re-type new password: # confirm
Adding password for user cent[iyunv@prox ~]# systemctl restart squid

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-141101-1-1.html 上篇帖子: squid cache manager(cachemgr.cgi)配置及使用 下篇帖子: 利用nginx+apache+mysql+php+memcached+squid搭建门户网站
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表