squid多ip出口认证
1:yum install gcc -y
yum install -y openssl*
2:
wget http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE9.tar.gz
3:
tar zxvf squid-2.7.STABLE9.tar.gz
4:
cd squid-2.7.STABLE9
5:
./configure --prefix=/usr/local/squid--enable-ssl --enable-async-io=320 --enable-icmp --enable-delay-pools --enable-kill-parent-hack --enable-snmp --enable-arp-acl --enable-htcp --enable-cache-digests --enable-removal-policies=heap,lru --enable-default-err-language=Simplify_Chinese --enable-x-accelerator-vary --enable-follow-x-forwarded-for --with-aufs-threads=320 --with-pthreads --with-dl --with-maxfd=65536 --enable-basic-auth-helpers=DB,NCSA --enable-digest-auth-helpers=password --enable-large-cache-files --with-large-files
6:
make
7:
make install
8:
cd /usr/local/squid/
9:
grep -v "^#" etc/squid.conf.default|uniq > etc/squid.conf
10:
vi /etc/squid.conf
在
acl CONNECT method CONNECT
http_access allow manager localhost
这两行中间加入:include "/usr/local/squid/etc/auth.conf"
在
icp_access deny all
http_port 3128这两行中间加入:always_direct allow all
最后broken_vary_encoding allow apache行后面的所有内容删除加入
forwarded_for off
header_access HTTP_VIA deny all
header_access VIA deny all
cache_effective_group daemon
cache_effective_user daemon
visible_hostname test
cache_dir aufs /usr/local/squid/cache 100 16 256
cache_store_log none
都修改添加完毕后,保存退出。
11:
紧接着我们来创建auth.conf。
vi /usr/local/squid/etc/auth.conf
auth_param basic program /usr/local/squid/libexec/ncsa_auth /usr/local/squid/etc/passwd
auth_param basic children 10
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
acl usergroup1 proxy_auth "/usr/local/squid/etc/ip1user"
acl usergroup2 proxy_auth "/usr/local/squid/etc/ip2user"
http_access allow usergroup1
http_access allow usergroup2
tcp_outgoing_address 服务器的IP1 usergroup1
tcp_outgoing_address 服务器的IP2 usergroup2
编辑完成后保存退出。
接下来是创建用户文件,vi /usr/local/squid/etc/ip1user,填入如下内容
user1
user2
保存退出。这里用户数量不限,每个用户名占用一行。
注意 如果不同用户不同IP 就需要上面配置的ip2user 那么就在创建一个用户文件 vi /usr/local/squid/etc/ip2user,写入
user3
user4
这样以此类推
12:
接下来创建用户的密码文件,第一次创建密码文件请使用下面的命令
htpasswd -cb /usr/local/squid/etc/passwd user1 111111(第一个用户名注意是用-cb 然后其他用户名-b)
htpasswd -b /usr/local/squid/etc/passwd user2 111111
以此类推
到此为止,配置文件等相关工作就基本完成了
13:
首先,mkdir cache,创建cache目录 然后执行,chown -R daemon.daemon /usr/local/squid/
最后sbin/squid -z对squid进行初始化
如果没有报错信息呢,初始化工作就算是做完了,
下面启动squid服务即可了,启动命令为
sbin/squid -ND &
然后通过下面的命令查看一下3128端口是否启动
netstat -ln|grep 3128如果出现下面的内容,说明squid服务已经正常运行了
tcp 0 0 0.0.0.0:3128 0.0.0.0:* LISTEN
14:
最后说说加密
首先使用下面命令可以生成测试用的证书:
openssl req -new -keyout key.pem -nodes -x509 -days 365 -out cert.pem (提示内容可以一路回车什么都不写)
然后修改squid的配置文件
vi etc/squid.conf
找到http_port 3128在下面加入https_port 443 cert=/usr/local/squid/cert.pem key=/usr/local/squid/key.pem
然后退出保存 重新启动SQUID
15
客户端(本机)设置
下载stunnel不管你是Windows还是Linux,都可以到这里下载:ftp://ftp.stunnel.org/stunnel/
将相应的stunnel压缩包解压缩或者安装,添加一个配置文件(stunnel.conf)至程序的目录:
client = yes
accept = 127.0.0.1:8080
connect = 服务器的IP:443
然后选择reload stunnel.conf
最后代理的IP就是127.0.0.1 端口就是8080
页:
[1]