linux(CentOS,fedora)下squid3安装及反向代理配置

下载源码包并解压
./configure --prefix=/usr/local/squid --enable-gnuregex --enable-async-io=20 --enable-icmp --enable-linux-netfilter --enable-kill-parent-hack --enable-snmp --disable-ident-lookups --enable-cache-digests --enable-arp-acl --enable-err-language="Simplify_Chinese"--enable-default-err-languages="Simplify_Chinese" --enable-poll --enable-linux-netfilter --enable-underscore
make
make install
mkdir /usr/local/squid/cache
chown -R nobody:nobody /var/squid/cache
chmod 777 /var/squid/cache -R
/usr/local/squid/sbin/squid -z
配置反向代理
打开etc/squid.conf文件

[b]acl[/b]
在文件里找到TAG: acl的位置,在其后加上我们的设置:

acl sites dstdomain .foo.com
acl sites dstdomain .bar.com

[b]http_access[/b]

在文件里找到TAG: http_access的位置,其后有一行注释:

# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS

我们就把自定义的规则放在这行的下面:

http_access allow sites

http_access的位置是很重要的,在下面有如下设置:

# And finally deny all other access to this proxy
http_access deny all

它会拒绝所有剩下的访问。

[b]http_port[/b]

在文件里找到TAG: http_port的位置,在其后加上我们的设置:

http_port 80 defaultsite=缺省站点 vhost

一般来说,vhost就足够了,不过加上defaultsite还是有好处的,毕竟,有的HTTP1.0客户端不发送Host头,在这种情况下系统有一个缺省值总比没有强。

[b]cache_peer[/b]

在文件里找到TAG: cache_peer的位置,在其后加上我们的设置:

cache_peer x.x.x.x parent 80 0 no-query originserver name=foo
cache_peer y.y.y.y parent 80 0 no-query originserver name=bar
80为web服务器访问端口

[b]cache_peer_domain[/b]

在文件里找到TAG: cache_peer_domain的位置,在其后加上我们的设置:

cache_peer_domain foo www.foo.com
cache_peer_domain bar www.bar.com

[b]cache_peer_access[/b]

在文件里找到TAG: cache_peer_access的位置,在其后加上我们的设置:

cache_peer_access foo allow sites

启动sbin/squid -s
如果不想查找dns,则增加-D选项
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值