使用Squid部署代理缓存服务(5)

72 http_port 3128 transparent
 73
 74 # Uncomment and adjust the following to add a disk cache directory.
 75 cache_dir ufs /var/spool/squid 100 16 256
[root@Squid-Server ~]# squid -k parse
[root@Squid-Server ~]# squid -z
2018/08/23 10:39:30| Squid is already running!  Process ID 2299
[root@Squid-Server ~]# iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-port 3128
[root@Squid-Server ~]# iptables -t nat -A POSTROUTING -s 172.16.10.0/24 -o ens35 -j SNAT --to 192.168.56.15
//此处网卡为对外的网卡
[root@Squid-Server ~]# service iptables save

反向代理
//主机设为NAT或者DHCP模式,配置文件编辑如下
http_port 192.168.56.15:80 vhost
cache_peer 39.104.16.126 parent 80 0 originserver

当你访问本机IP时访问的却是目标站点

更多Squid相关教程见以下内容:

Linux下Squid代理缓存服务环境部署  https://www.linuxidc.com/Linux/2016-10/136594.htm
Squid:实现高速的Web访问 https://www.linuxidc.com/Linux/2013-04/83512.htm
CentOS 6.2 编译安装Squid 配置反向代理服务器 https://www.linuxidc.com/Linux/2012-11/74529.htm
Squid代理http和https方式上网的操作记录  https://www.linuxidc.com/Linux/2017-02/140398.htm
Squid代理服务器搭建及配置 https://www.linuxidc.com/Linux/2016-03/129392.htm
CentOS 6.4下DNS+Squid+Nginx+MySQL搭建高可用Web服务器 https://www.linuxidc.com/Linux/2014-04/99984.htm
配置squid代理服务器加快网站访问速度  https://www.linuxidc.com/Linux/2017-05/143460.htm

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

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/a4f48c26856db042d61fe9af7f375c77.html