您的位置:首页 > 运维架构 > 反向代理

Window 2003 R2下安装squid透明代理

2016-05-17 22:10 579 查看
1.下载windows下squid安装包地址:

http://squid.acmeconsulting.it/download/squid-2.7.STABLE8-bin.zip
 
2.将下载的squid安装包解压并放到被安装的windows 2003 R2上c盘,c:\squid
 
3.运行cmd,进入目录c:\squid\etc
a) copy squid.conf.default squid.conf
b) copy mime.conf.default mime.conf
c) copy cachemgr.conf.default cachemgr.conf
d) copy squid_radius_auth.conf.default squid_radius_auth.conf
 
4.修改配置文件squid.conf
 
# Recommended minimum configuration:
acl all src 0.0.0.0/0  #定义所有源网段,默认为所有地址
acl manager proto cache_object
acl localhost src 127.0.0.1/32 #定义环回主机源地址
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 #定义允许访问的目的网段
 
#acl localhost src 0/0  #针对本机没有必要设置全部网段
 
# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
#定义内部主机源网段分别为10.0.0.0/8、172.16.0.0/12、192.168.0.0/16,  localnet为自定义名称,用于注册那些网段可以上网
acl localnet src 10.0.0.0/8 #RFC1918 possible internal network
acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
 
#此行数用于定义内网ipv6地址段,暂时不用注释即可
#acl localnet src fc00::/7   # RFC 4193 local private network range    
#acl localnet src fe80::/10   # RFC 4291 link-local (directly plugged) machines(本机ipv6地址类似环回)
 
#将端口进行定义,方便以后配置(端口名称可以自定义)
acl SSL_ports port 443 #https
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT
 
forwarded_for transparent
 
# Recommended minimum Access Permission configuration:
# Only allow cachemgr access from localhost
#配置允许或禁止那些源ip或端口访问
http_access allow manager localhost
http_access deny manager
 
# Deny requests to certain unsafe ports
#禁止未定义的端口通信,此处使用的正则表达式,“!”表示取反
http_access deny !Safe_ports
 
# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports
 
# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost
 
#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#
 
# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
# 自定义的源ip网段
http_access allow localnet
http_access allow localhost
http_access allow all
 
# And finally deny all other access to this proxy
http_access deny all
 
# Squid normally listens to port 3128
# squid 默认启用3128,此处更改为31288
http_port 31288
 
# We recommend you to use at least the following line.
hierarchy_stoplist cgi-bin ?
 
# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 100 16 256
 
# Leave coredumps in the first cache dir
#主要用于备份成的core文件
#注意,在window 2003 R2要创建对应目录,否则会报错
coredump_dir c:/squid/var/squid
 
# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320
 
#access cache.log 缓存日志的存放位置
#注意,在window2003 R2要创建对应目录,否则会报错
cache_dir ufs c:/squid/var/cache 20480 16 256
cache_log c:/squid/var/cache/cache.log
 
#stroage the path of the pid
#主要用于记录进程的pid,定义的目录一定要正确
pid_filename c:/squid/var/logs/squid.pid
 
#set visible_hostname,注册开启代理的主机名称,注释此选项会warning
visible_hostname iZ25khcmcysZ
 
5.squid命令选项解释
简单介绍一下squid常用选项
C:\squid\sbin>squid.exe -h
Usage: squid [-hirvzCDFIRYX] [-d level] [-s | -l facility] [-f config-file] [-u port] [-k signal] [-n name] [-O command-line]
       -f file   Use given config-file instead of
                 c:/squid/etc/squid.conf #可以自定义配置文件路径
       -i Installs as a Windows Service.
       -k reconfigure|rotate|shutdown|interrupt|kill|debug|check|parse
                 Parse configuration file, then send signal to
                 running copy (except -k parse) and exit.
       -n name   Specify Windows Service name to use for service operations default is: Squid.
       -r        Removes a Windows Service (see -n option).
       -z        Create swap directories
       -X        Force full debugging. #此选项主要用于开启squid服务,并且打印服务启动的过程问题,便于排除错误问题
 
6.常见错误问题追踪
使用squid -X 显示debug信息启动信息
a) 开启主机代理的主机名注册,配置选项visible_hostname iZ25khcmcysZ
 
b) WARNING提示信息,配置选项冗余,如
acl localhost src 0/0 定义本机所有地址,没有必要的
c) ERROR 提示信息,配置选项错误等
pid_filename 定义的路径提示 not found
Cache_log  定义的路径提示 not found
7.在IE浏览器中,修改对应ip和代理端口(此处不做详细介绍)

ok!!!
 
注意:使用squid -X 强制显示debug信息以及进程启动过程中出现哪些失败进程;当启动成功后,会显示进程pid文件。
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: