首先参照
用squid再次疯狂加速你的web
昨天给大家介绍了用tmpfs加速你的linux服务器,我觉得还是不够过瘾,今天趁热打铁继续学了一招,用squid来疯狂加速你的web网站,对自己web网站速度不满意的话,不妨试验一下我下面推荐的方法。
首先你得有squid代理服务器,怎么装我就不讲了,用redhat的直接使用她的rpm安装就行。
配置squid的配置文件,使其支持httpd加速器工作方式。
编辑“squid.conf”文件(vi /etc/squid/squid.conf),增加下面内容:
http_port 80
icp_port 0
acl QUERY urlpath_regex cgi-bin ?
no_cache deny QUERY
cache_mem 16 MB
cache_dir ufs /tmp 256 16 256
log_icp_queries off
buffered_logs on
emulate_httpd_log on
redirect_rewrites_host_header off
half_closed_clients off
acl all src 0.0.0.0/0.0.0.0
http_access allow all
cache_mgr admin
cache_effective_user squid
cache_effective_group squid
httpd_accel_host 210.51.0.124
httpd_accel_port 81
http_port”参数指定Squid监听浏览器客户请求的端口号,这里当然是80了
cache_dir ufs /tmp 256 16 256
cache_dir参数设定使用的存储系统的类型。一般情况下都类型应该是ufs,目录应该是“/tmp”,在该目录下使用的缓冲值为256MB,允许在“/tmp”下创建的第一级子目录数为16,每个第一级子目录下可以创建的第二级子目录数量为256
选项“httpd_accel_host”和“httpd_accel_port”定义了真正的Web服务器的主机名和端口号。在这里的配置中,真正的 HTTP服务器运行在IP地址为210.51.0.124 (
www.5ilinux.com)的主机上,运行端口为81。
ok,squid设置完毕。
接着设置apache,很简单,只要把你的httpd监听端口设置成81就成,然后重启你的apache。
接着重启你的squid服务,现在你访问你的web网站,已经是用了squid的http加速工作模式,你可以通过看squid的log日记看到他的运行情况。
我还是没搞明白怎么配合使用虚拟主机,以上方法只实现一个域名,不知大家有没有做过虚拟主机squid加速,提点一下吧
根据文章的介绍已经可以调出一个好用的反向代理了。不过我在测试中发现这个代理可以让别人设置这个反向代理作为代理服务器使用。这样出于安全及资源反面都有影响。我稍微做了点修改。
acl规则如下
acl acceleratedProtocol protocol HTTP
acl acceleratedPort port 80
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 myips dst 202.155.214.62/32
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
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 GET
acl mycon method GET
acl myip method CONNECT
no_cache deny QUERY
http_access deny myip
http_access deny !myips
http_access allow all
http_access deny !Safe_ports
http_access allow localhost
http_access deny all
通过查看squid的 access.log 会看到有 TCP_DENIED/403 相关的语句。这就是限制已经生效了
请大家回帖指出问题。