Linux squid 缓存服务器

安装:

tar -zxf squid-3.4.6.tar.gz
tar -zxf sarg-2.3.7.tar.gz

编译配置

./configure --prefix=/usr/local/squid --sysconfdir=/etc --enable-arp-acl --enable-linux-netfilter --enable-linux-tproxy --enable-async-io=100 --enable-err-language="Simplify_Chinese" --enable-underscore --enable-poll --enable-gnuregex
make && make install

链接-添加到PATH路径

ln -s /usr/local/squid/sbin/* /usr/local/sbin/
ln -s /usr/local/squid/bin/* /usr/local/bin/

运行用户与权限

useradd -s /sbin/nologin -M squid
chown -R squid:squid /usr/local/squid/var/

启动配置文件

编辑squid.conf 文件,添加: vim squid.conf

cache_dir ufs /usr/local/squid/var/cache/squid 100 16 256
coredump_dir /usr/local/squid/var/cache/squid
cache_effective_user squid
cache_effective_group squid
visible_hostname 主机名
http_port 主机内网地址:端口号 transparent

反向代理的:

http_port 80 accel vhost
http_access allow all
cache_peer web地址 parent 80 0 originserver round-robin weight=1
cache_peer web地址 parent 80 0 originserver round-robin weight=1
visible_hostname squid.david.dev

启动

配置文件测试:

squid -k parse

初始化:

squid -z

启动服务: squid

防火墙开放

iptables -t nat -I PREROUTING -s 192.168.10.0/24 -p tcp --dport 80 -j REDIRECT --to 3128