Linux学习笔记 --Squid

本文详细介绍Squid正向及反向代理的配置过程,包括安装Squid、修改配置文件实现不同代理功能,以及如何在浏览器中设置代理访问网站。通过实际案例演示了单代理、多代理轮询等应用场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Squid


1.Squid正向代理

 

【真机】

[root@foundation66 ~]# yum install squid -y



[root@foundation66 ~]# systemctl start squid

 

[root@foundation66 ~]# vim /etc/squid/squid.conf

 56 http_access deny all ------> http_access allow all


 62 #cache_dir ufs /var/spool/squid 100 16 256 ------> cache_dir ufs /var/spool/squid 100 16 256

 

[root@foundation66 ~]# systemctl restart squid

 

【虚拟机】

 

浏览器 -> Edit -> Preferences -> Advanced -> Network -> Settings -> Manual proxy cOnfiguration -> HTTP Proxy 172.25.254.29 Port 3128 -> OK

 


2.Squid反向代理加速

 

1)单代理

 

【无apache虚拟机】

 

[root@localhost ~]# yum install squid -y



[root@localhost ~]# systemctl start squid

 

[root@localhost ~]# vim /etc/squid/squid.conf

 56 http_access deny all ------> http_access allow all

 59 http_port 3128 ------> http_port 80 vhost vport

 60 【添加】cache_peer 172.25.254.129 parent 80 0 no-query


 62 #cache_dir ufs /var/spool/squid 100 16 256 ------> cache_dir ufs /var/spool/squid 100 16 256

 


[root@localhost ~]# systemctl restart squid

 

浏览器访问 172.25.254.229

 


2)多代理

 

【轮叫】

 

[root@localhost ~]# vim /etc/squid/squid.conf

 56 http_access deny all ------> http_access allow all

 59 http_port 3128 ------> http_port 80 vhost vport

 60 【添加】cache_peer 172.25.254.129 parent 80 0 no-query originserver name=route1 round-robin weight=3

 61 【添加】cache_peer 172.25.254.66 parent 80 0 no-query originserver name=route2 round-robin weight=1

 62 【添加】cache_peer_domain www.westos.com route1 route2


 64 #cache_dir ufs /var/spool/squid 100 16 256 ------> cache_dir ufs /var/spool/squid 100 16 256

 


##no-query 不查询  

##originserver当父级节点为route1时做加速

##round-robin检测轮叫次数(超过限制转向下一个代理)

##weight= 轮叫限制

 

[root@localhost ~]# systemctl restart squid

 

浏览器访问 172.25.254.229 刷新网页


刷新3次后


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值