阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Squid 反向代理CDN搭建配置

130次阅读
没有评论

共计 2835 个字符,预计需要花费 8 分钟才能阅读完成。

因为公司业务需要,需要自己在某地搭建一个 cdn 节点,通过 DNSpod 智能解析和 squid 配合可以搭建一个节点。

安装路径:/usr/local/squid

1, 安装 squid

下载 http://www.squid-cache.org/Versions/v3/3.4/squid-3.4.8.tar.gz

#yum -y install gcc gcc-c++        #安装编译用的插件

# Tar xvf squid-3.4.8.tar.gz

#cd squid-3.4.8

#cd /usr/local

#mkdir squid              # 新建一个名为 squid 目录

#cd  squid-3.4.8

#./configure –prefix=/usr/local/squid      #编译

#make && make install                #安装

 

配置 1

新建用户 squid 和用户组 squid

#groupadd squid

#useradd -g squid -s /sbin//nologin squid

配置 squid 文件

#vi /usr/local/squid/etc/squid.conf  #内容请在最下面查看

 

visible_hostname chengdu.sz1card1.com

cache_effective_user squid

cache_effective_group squid

 

http_port 80 accel vhost vport

 

cache_peer 192.168.1.11 parent 80 0 no-query originserver round-robin  name=proxy1

cache_peer 192.168.1.12 parent 80 0 no-query originserver round-robin  name=proxy2

cache_peer 192.168.1.13 parent 80 0 no-query originserver round-robin  name=proxy3

cache_peer_domain proxy1 server.1card1.cn

cache_peer_domain proxy2 www.abc.cn

cache_peer_domain proxy2 www.xxxx.cn

cache_peer_domain proxy3 www.linuxidc.com

 

http_access allow all

 

cache_log /usr/local/squid/var/logs/cache.log

access_log /usr/local/squid/var/logs/access.log squid

cache_dir ufs /usr/local/squid/var/cache 1000 16 256

 

maximum_object_size 10240 KB

maximum_object_size_in_memory 1024 KB

cache_mem 1024 MB

 

 

配置 2

#chown -Rf squid:nobody /usr/local/squid

初始化 squid.conf 里配置的 cache 目录,就是建立了一堆的目录:

#sudo /usr/local/squid/sbin/squid -z

启动 squid 后台运行

sudo /usr/local/squid/sbin/squid -s

检查一下进程是否存在:ps -ef|grep squid

 

 

 

 

 

Squid 日常维护过程中,常用的一些命令:

1,初始化你在 squid.conf 里配置的 cache 目录

squid -z

如果有错误提示,请检查你的 cache 目录的权限。

可以使用使用更改目录权限:

chown -R squid:squid /cache 目录

2,对你的 squid.conf 排错,即验证 squid.conf 的 语法和配置。

squid -k parse

如果 squid.conf 有语法或配置错误,这里会返回提示你,如果没有返回,尝试启动 squid。

3,在前台启动 squid,并输出启动过程。

/usr/local/squid/sbin/squid -N -d1

如果有 ready to server reques 相关信息,说明 Squid 启动成功。

 

 

Squid 作为系统服务重启脚本

 

 

#!/bin/bash #

chkconfig: 345 61 61

# description: squid is a web cache server

# processname: squid

. /etc/rc.d/init.d/functions

case $1 in

“start”) /usr/local/squid/sbin/squid -s

if [$? == “0”];then

echo “squid start ok”

else

echo “please check the log”

fi

;;

“stop”) /usr/local/squid/sbin/squid -k shutdown

if [$? == “0”];then

echo “squid stop ok”

else

echo “please check the log”

fi

;;

“restart”)

/usr/local/squid/sbin/squid -k shutdown

if [$? == “0”];then

/usr/local/squid/sbin/squid -s

if [$? == “0”];then

 echo “squid restart ok”

else

/usr/local/squid/sbin/squid -s

if [$? == “0”];then

 echo “squid restart ok”

else

echo “please check the log”

fi

fi

fi

;;

 *)

echo “Usage only start|stop|restart”

;;

esac

把这个文件放到 /etc/init.d/ 目录下并命名为 squid

chmod +x /etc/init.d/squid

chkconfig –add squid

如果出现 squid 服务不支持 chkconfig

则去更改上面的  chkconfig: 345 61 61    这几个数字

配置 Squid 代理 http 和 rsync http://www.linuxidc.com/Linux/2013-05/84642.htm

Squid:实现高速的 Web 访问 http://www.linuxidc.com/Linux/2013-04/83512.htm

CentOS 6.2 编译安装 Squid 配置反向代理服务器 http://www.linuxidc.com/Linux/2012-11/74529.htm

简单配置 Squid 代理和反向代理 http://www.linuxidc.com/Linux/2014-04/99465.htm

CentOS 6.4 下 DNS+Squid+Nginx+MySQL 搭建高可用 Web 服务器 http://www.linuxidc.com/Linux/2014-04/99984.htm

Squid 的详细介绍 :请点这里
Squid 的下载地址 :请点这里

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计2835字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中