利用squid给公司内网加速..
公司里的编辑 和 监控人员的工作就是天天再刷帖~~ 一个帖里面又有很多图片罗。导致公司内部网络 有点牛车。。所以很需要我在公司内部的服务器上做一个 内部CDN 。针对公司的网站进行前端CACHE。 这样的话~~ 哇咔咔 公司内部网速就快罗还是进行简单的安装吧。
Feebsd 系统
#/usr/ports/www/squid
# make install clean
# echo"squid_user=root" >> /etc/rc.conf 因为要启动 80端口 1024口以下的都必须 root 权限才行啦
# echo "squid_enable=yes" >> /etc/rc.conf
启动前创建存储目录:
/usr/local/sbin/squid -z
squid 的配置:
http_port 80 vhost vportdns_nameservers 202.103.224.68 202.103.224.69visible_hostname beihai365cache_dir ufs /var/spool/squid 2048 16 256cache_mem 1000 MBcache_mgr 237852571@qq.comredirect_children 30cache_access_log /var/log/squid/access.logcache_log /var/log/squid/cache.logcache_store_log /var/log/squid/store.logcache_peer 222.216.28.180 parent 80 0 no-query originserver name=ednscache_peer 222.216.28.226 parent 80 0 no-query originserver name=imgcache_peer_domain edns www.beihai365.comcache_peer_domain img img.beihai365.comacl webserver dst 222.216.28.180acl imgserver dst 222.216.28.226http_access allow imgserverhttp_access allow webserver
因为只是测试。我没有给内部的DNS 做 zone 。所以暂时现在hosts文件里面进行 域名映射先。
# Copyright (c) 1993-1999 Microsoft Corp.## This is a sample HOSTS file used by Microsoft TCP/IP for Windows.## This file contains the mappings of IP addresses to host names. Each# entry should be kept on an individual line. The IP address should# be placed in the first column followed by the corresponding host name.# The IP address and the host name should be separated by at least one# space.## Additionally, comments (such as these) may be inserted on individual# lines or following the machine name denoted by a '#' symbol.## For example:## 102.54.94.97 rhino.acme.com # source server# 38.25.63.10 x.acme.com # x client host127.0.0.1 localhost192.168.1.241www.beihai365.com192.168.1.241img.beihai365.com
好了。开始刷新网站。然后看下是否有 HIT还是 MISS .. 用 firebug 看也行 看x-cache 标记. 如下:
X-Cache
HIT from beihai365Via1.0 beihai365 (squid/3.0.STABLE25)
看到就知道 是经过了 CDN 处理了而且命中了
没有 firebug 的朋友就直接看日志啦
beihai365test# cat /var/log/squid/access.log | grep '329_437921_c975259b1f1ed19'1299919890.545 5074 192.168.1.238 TCP_MISS/200 380347 GET http://img.beihai365.com/bbs/Mon_1103/329_437921_c975259b1f1ed19.jpg - FIRST_UP_PARENT/img image/jpeg1299919899.490 16 192.168.1.238 TCP_HIT/200 380355 GET http://img.beihai365.com/bbs/Mon_1103/329_437921_c975259b1f1ed19.jpg - NONE/- image/jpeg1299919913.489 15 192.168.1.238 TCP_HIT/200 380355 GET http://img.beihai365.com/bbs/Mon_1103/329_437921_c975259b1f1ed19.jpg - NONE/- image/jpeg1299919915.818 20 192.168.1.238 TCP_HIT/200 380355 GET http://img.beihai365.com/bbs/Mon_1103/329_437921_c975259b1f1ed19.jpg - NONE/- image/jpeg
哦也~~ 准备整合到 内部 DNS 里面去~~
版权声明:本文为博主原创文章,未经博主允许不得转载。
页:
[1]