Squid 代理服务之透明代理服务器架构搭建

本文详细介绍Squid透明代理服务器的配置步骤,包括修改配置文件、开启路由转发及防火墙规则调整等内容,并通过实际测试验证了配置的有效性。


1. 服务器配置

服务器 主机名 IP地址 主要软件
Squid 服务器 squid_server 外网ens33:192.168.10.20 | 内网ens37:10.0.0.100 squid
Web 服务器 web_server 内网 10.0.0.200 apache
Win10 客户端 外网 192.168.10.85 edge 浏览器

在这里插入图片描述

2. Squid 服务器部署

2.1 修改 Squid 配置文件

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

# And finally deny all other access to this proxy
http_access allow all
http_access deny all

# Squid normally listens to port 3128
##60行,修改,添加提供内网服务的网卡IP地址,和支持透明代理选项transparent
http_port 192.168.10.20:3128 transparent
cache_effective_user squid
cache_effective_group squid
cache_mem 64 MB
reply_body_max_size 10 MB
maximum_object_size 4096 KB

[root@squid_server ~]# systemctl restart squid

2.2 开启路由转发,实现本机中不同网段的地址转发

[root@squid_server ~]#echo 'net.ipv4.ip_forward = 1' >> /etc/sysctl.conf
[root@squid_server ~]#sysctl -p
net.ipv4.ip_forward = 1

2.3 修改防火墙规则

[root@squid_server ~]#iptables -F
[root@squid_server ~]#iptables -t nat -F
[root@squid_server ~]#iptables -t nat -I PREROUTING -i ens33 -s 192.168.10.0/24 -p tcp --dport 80 -j REDIRECT --to 3128
#用于转发 http 协议,将访问端口重定向到 3128
[root@squid_server ~]#iptables -t nat -I PREROUTING -i ens33 -s 192.168.10.0/24 -p tcp --dport 443 -j REDIRECT --to 3128
#用于转发 https 协议,将访问端口重定向到 3128<
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值