pony

抄袭是一种美德

【原】squid简单应用

     squid的介绍大家可以从网上搜出一大堆的东东来。推荐一个不错的文档:
     http://home.arcor.de/mailerstar/jeff/squid/index.html
     squid的安装按照上面的步骤去做就可以了。其实squid最重要的还是配置和理解概念。
     首先squid是非常重要的反向代理的工具。关于反向代理和正向代理可以这样理解:
     1.正向代理:根正苗红的代理。客户端发来的请求,到了这个代理A处,它便直接将请求转发到B了。这要求客户端合理配置。
     2.反向代理:有点像动态的include标签。客户端发来的请求,到了代理A处,它会向目标B发出请求,得到结果返回给客户端。
     squid作为反响代理,一般理解两个端口的概念就可以了。一个是监听的端口,即http_port 默认是3128。还有一个就是代理的端口。比如8080.ftp的21端口等等。
     这些端口可以这样理解:用户发来请求到3128. squid会从代理的端口中找到比如8080.进行反向代理。
    
     squid的简单的命令应用:
     1 squid -k parse 建议修改完配置文件squid.conf。便运行下,进行校验。
     2.squid -z 初始化cache目录。
     3.squid -d1 执行级别1.在前台运行
     4.squid -s 在后台执行。执行完用ps aux|grep squid可以看到两个squid进程。
     5.squid -k reconfigure:修改完配置文件,可以这样重读。但是如果修改了cache目录,则需要再执行squid -z后执行这个。
     6.squid -k restart kill shutdown  重启。杀死进程。关闭请求命令。
 
     附录:一个简单的squid配置。在window下。
visible_hostname pony.asia
#Recommended minimum configuration:
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443
acl Safe_ports port 80        # http
acl Safe_ports port 8080    # tomcat
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


http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow all
icp_access allow all

#http_port 3128
http_port 80 accel vhost vport
cache_peer 127.0.0.1 parent 8080 0 no-query originserver

cache_mem 8 MB
maximum_object_size_in_memory 8 KB
memory_replacement_policy lru
cache_replacement_policy lru

cache_dir ufs c:/squid/cache 100 16 256

store_dir_select_algorithm least-load

max_open_disk_fds 0

minimum_object_size 0 KB

maximum_object_size 4096 KB


access_log c:/squid/logs/access.log squid

cache_log c:/squid/logs/cache.log

cache_store_log c:/squid/logs/store.log

mime_table c:/squid/etc/mime.conf

pid_filename c:/squid/logs/squid.pid


coredump_dir c:/squid/var/cache

posted on 2009-09-17 12:04  马森  阅读(570)  评论(0编辑  收藏  举报

导航