搭建squid代理服务器,并启用简单认证

一、安装Proxy需要的squid软件


yum -y install squid


二、配置文件位置


/etc/squid/squid.conf


#配置文件是可以代理所有私网地址的,如果有其他地址需要请自行添加


三、开启缓存功能


cache_dir ufs /var/spool/squid 100 16 256


#认改行是被注释掉的,如需开启缓存,将注释符去掉即可。


四、开启认证功能


  1. 软件安装


[root@localhost ~]# rpm -ql squid | grep ncsa
/usr/lib64/squid/ncsa_auth #查看是否存在验证文件,安装squid时会自动安装上。
/usr/share/man/man8/ncsa_auth.8.gz


[root@localhost ~]# yum -y install httpd #安装apache软件

[root@localhost ~]# rpm -ql httpd | grep htpasswd

/usr/bin/htpasswd #需要这个账号密码建立命令

/usr/share/augeas/lenses/dist/htpasswd.aug


2.配置文件

vim /etc/squid/squid.conf



添加用户认证

#用户认证需要添加

auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic credentialsttl 2 hours
auth_param basic realm Example.com's Squid proxy-caching
acl auth_user proxy_auth required
http_access allow auth_user

注释:

第一行:选择的认证方式为basic,认证程序路径和密码文件路径。

第二行:认证程序的进程数

第三行:认证有效时间

第四行:认证领域内容,上面定义的web浏览需要输入用户密码

第五,六行:设置允许认证的用户访问

生成密码文件

在第一行中的 /etc/squid/passwd 文件可以使用下面方法生成,在装有apache的机器上运行

htpasswd -c /etc/squid/passwd auth_user

以上的auth_user替换为认证的用户 比如zhangsan

password:


五、重启服务


[root@localhost ~]# service squid restart

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Centos下搭建性能监控Spotlight
CentOS 6.3下Strongswan搭建IPSec VPN
在CentOS6.5上安装Skype与QQ
阿里云基于centos6.5主机VPN配置
CentOS 6.3下配置multipah
CentOS安装、配置APR和tomcat-native
centos6.5下postgres-XC集群安装与配置
CentOS 6使用openssl搭建根CA
CentOS6.6中安装VNC server
CentOS下更新Python最新版本
Centos安装pycurl
CentOS 7 安装PostGIS
CentOS 7.1PXE网络自动化安装
CentOS下ffmpeg与第三方编码编译安装
CentOS 6.4安装配置squid
CentOS6.5 安装配置drbd
CentOS6.4 安装jenkins
centos安装增强工具
CentOS6.4安装配置redis
CentOS 6上部署OpenVPN Server