Squid 透明 HTTP 代理服务器安装配置


简介

squid 是一个缓存服务器,通常用来作Web加速的,本文中将使用squid来作透明的http代理服务器。

安装

mkdir /var/log/squid
chown squid.squid /var/log/squid
mkdir /var/spool/squidss
chown squid.squid /var/spool/squid

配置

cat >/etc/squid/squid.conf <<DELIM
http_port 3128 transparent
icp_port 0
#htcp_port 0
snmp_port 0

acl all src all
acl adminfellow src 127.0.0.1/32
acl allowfellow src 0.0.0.0/0
acl manager proto cache_object
acl connect method CONNECT
acl purge method PURGE

http_access allow allowfellow
http_access allow adminfellow
http_access allow manager adminfellow
#http_access deny manager
http_access allow adminfellow purge
#http_access deny purge
http_access deny all
#icp_access allow all

hierarchy_stoplist cgi-bin ?
hierarchy_stoplist -i ^https:\\ ?
no_cache deny all

emulate_httpd_log on
cache_store_log none
cache_access_log none
#cache_log /dev/null
access_log /var/log/squid/access.log squid
coredump_dir /var/spool/squid

#cache_dir
#cache_mem 8m
cache_mgr admin@squid
#the hostname will display in the error messages
visible_hostname localhost
error_directory  /usr/share/squid/errors/Simplify_Chinese
#error_map 404.html 404
DELIM

启动

squid -f /etc/squid/squid.conf