设为首页 收藏本站
查看: 1791|回复: 0

[经验分享] 简单squid 缓存服务器配置

[复制链接]

尚未签到

发表于 2018-12-28 10:12:19 | 显示全部楼层 |阅读模式
  简单squid 缓存服务器配置--献给和我一样的新手
环境介绍:
服务          主机名             IP
Squid         cdn.fantong.com      192.168.1.125
Web          db.fantong.com      192.168.1.122
内网测试需要绑定HOST文件

服务端:
Squid 版本选择 squid-3.0.STABLE8.tar.gz

wget http://ftp.vim.org/internet/squid/squid-3.0.STABLE8.tar.gz

客户端
安装http    自行写个首页文件能访问.

Useradd squid
Groupadd squid

安装squid
文件放在/usr/local/src 下
tar –zxvf  squid-3.0.STABLE8.tar.gz
/usr/local/src/squid-3.0.STABLE8
安装squid 的配置较多 建议做个shell 来运行
#!/bin/bash
./configure --prefix=/usr/local/squid3 \
--enable-dlmalloc \
--enable-debug-cbdata \
--enable-async-io=100 \
--with-pthreads \
--enable-storeio="aufs,coss,diskd,ufs" \
--enable-removal-policies="heap,lru" \
--enable-icmp \
--enable-delay-pools \
--enable-useragent-log \
--enable-referer-log \
--disable-wccp \
--disable-wccpv2 \
--enable-kill-parent-hack \
--enable-arp-acl \
--enable-snmp \
--enable-default-err-language=Simplify_Chinese \
--enable-err-languages="Simplify_Chinese English" \
--disable-poll \
--enable-epoll \
--disable-ident-lookups \
--disable-internal-dns \
--enable-truncate \
--enable-underscores \
--enable-basic-auth-helpers="NCSA" \
--enable-stacktrace \
--with-winbind-auth-challenge \
--enable-large-cache-files --with-large-files \
--with-maxfd=32768\
--enable-ssl \
--enable-x-accelerator-vary


Make && make install
#创建缓存文件夹和日志文件夹并更改属主 属组
Mkdir –p /usr/local/squid3/var/cache
Mkdir –p /usr/local/squid3/var/logs
Chown squid:squid /usr/local/squid3/var/cache
Chown squid:squid /usr/local/squid3/var/logs

修改/usr/local/squid3/etc/squid.conf

Echo  > squid.conf
清空文件  (里面的选项太多了2000多行)

cache_effective_user squid
cache_effective_group squid
#必须要有的主机名
visible_hostname     cdn.fantong.com
#配置为http 加速模式
http_port 80 accel vhost vport
icp_port 3130
#下面的配置有待研究
#cache_peer db.fantong.com sibling 80 3130
#cache_peer squid3.ibm.com.cn sibling 80 3130

#这个主要是用于配置如果当前缓存中如果没有请求的内容,就去兄弟服务器或者父亲服务器或者源地址去取需要的内容。
#cache_peer 192.168.1.122 parent 80 0 no-query originserver round-robin name=webServer1

cache_peer 192.168.1.122 parent 80 0 no-query originserver round-robin name=cdn.fantong.com

#acl localnet src 192.168.1.125
acl all src
http_access allow all
icp_access allow all
cache_log /usr/local/squid3/var/logs/cache.log
access_log /usr/local/squid3/var/logs/access.log squid
cache_dir ufs /usr/local/squid3/var/cache/ 1000 16 256
maximum_object_size 10240 KB
maximum_object_size_in_memory 512 KB
cache_mem 256 MB

检测配置文件是否正确:
squid -k parse

初始化squid
/usr/local/squid2/sbin/squid –z

启动squid
/usr/local/squid3/sbin/squid -Nd1

查看是否启动
ps aux |grep squid



测试是否命中

curl -I http://192.168.1.125
HTTP/1.0 200 OK
Date: Wed, 18 Jul 2012 10:03:31 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 13 Jul 2012 02:02:23 GMT
ETag: "180f68-6d-789089c0"
Accept-Ranges: bytes
Content-Length: 109
Content-Type: text/html; charset=UTF-8
Age: 980
X-Cache: HIT from cdn.fantong.com
Via: 1.0 cdn.fantong.com (squid/3.0.STABLE8)
Connection: close

倒数第3行x-cache:HIT   代表命中              x-cache:miss 代表未命中

以上为简单squid 配置,如果有错误请联系QQ:57674891 指正。第3次写技术博客希望大家多多包涵。




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-656761-1-1.html 上篇帖子: squid.conf中cache_peer参数详解 下篇帖子: 分享squid缓存服务器配置-之conf配置文件的详细介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表