squid-基于rockylinux8配置内网代理访问阿里云软件源

目录

1.配置代理服务器

2.配置内网服务器


1.配置代理服务器

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| root@localhost \~# yum install -y squid |
| Installed: libecap-1.0.1-2.module+el8.9.0+1437+df5ea8f0.x86_64 perl-Carp-1.42-396.el8.noarch perl-DBI-1.641-4.module+el8.9.0+1495+f278a004.x86_64 perl-Data-Dumper-2.167-399.el8.x86_64 perl-Digest-1.17-395.el8.noarch perl-Digest-MD5-2.55-396.el8.x86_64 perl-Digest-SHA-1:6.02-1.el8.x86_64 perl-Encode-4:2.97-3.el8.x86_64 perl-Errno-1.28-423.el8_10.x86_64 perl-Exporter-5.72-396.el8.noarch perl-File-Path-2.15-2.el8.noarch perl-File-Temp-0.230.600-1.el8.noarch perl-Getopt-Long-1:2.50-4.el8.noarch perl-HTTP-Tiny-0.074-3.el8.noarch perl-IO-1.38-423.el8_10.x86_64 perl-IO-Socket-IP-0.39-5.el8.noarch perl-IO-Socket-SSL-2.066-4.module+el8.9.0+1517+e71a7a62.noarch perl-MIME-Base64-3.15-396.el8.x86_64 perl-Math-BigInt-1:1.9998.11-7.el8.noarch perl-Math-Complex-1.59-423.el8_10.noarch perl-Mozilla-CA-20160104-7.module+el8.9.0+1521+0101edce.noarch perl-Net-SSLeay-1.88-2.module+el8.9.0+1517+e71a7a62.x86_64 perl-PathTools-3.74-1.el8.x86_64 perl-Pod-Escapes-1:1.07-395.el8.noarch perl-Pod-Perldoc-3.28-396.el8.noarch perl-Pod-Simple-1:3.35-395.el8.noarch perl-Pod-Usage-4:1.69-395.el8.noarch perl-Scalar-List-Utils-3:1.49-2.el8.x86_64 perl-Socket-4:2.027-3.el8.x86_64 perl-Storable-1:3.11-3.el8.x86_64 perl-Term-ANSIColor-4.06-396.el8.noarch perl-Term-Cap-1.17-395.el8.noarch perl-Text-ParseWords-3.30-395.el8.noarch perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch perl-Time-Local-1:1.280-1.el8.noarch perl-URI-1.73-3.el8.noarch perl-Unicode-Normalize-1.25-396.el8.x86_64 perl-constant-1.33-396.el8.noarch perl-interpreter-4:5.26.3-423.el8_10.x86_64 perl-libnet-3.11-3.el8.noarch perl-libs-4:5.26.3-423.el8_10.x86_64 perl-macros-4:5.26.3-423.el8_10.x86_64 perl-parent-1:0.237-1.el8.noarch perl-podlators-4.11-1.el8.noarch perl-threads-1:2.21-2.el8.x86_64 perl-threads-shared-1.58-2.el8.x86_64 squid-7:4.15-10.module+el8.10.0+2080+49064dbd.9.x86_64 Complete! |
| root@localhost \~# systemctl enable squid |
| Created symlink /etc/systemd/system/multi-user.target.wants/squid.service → /usr/lib/systemd/system/squid.service. |
| root@localhost \~# mv /etc/squid/squid.conf /etc/squid/squid.conf.bak root@localhost \~# vim /etc/squid/squid.conf |
| # 监听内网IP和端口(例如,在本机所有IP的3128端口监听) http_port 3128 # 定义内网网段(例如,假设您的内网段是 10.0.0.0/24) acl local_net src 10.9.254.0/24 acl aliyun_domain dstdomain .aliyun.com .alibabacloud.com .aliyuncs.com .alicdn.com # 允许定义的本地网络使用代理 http_access allow local_net aliyun_domain # 默认拒绝所有其他访问(重要安全设置) http_access deny all # 配置DNS服务器(可选但建议,可设置为企业内网DNS或公共DNS) dns_nameservers 223.5.5.5 223.6.6.6 # 启用日志记录(便于排查) access_log /var/log/squid/access.log cache_log /var/log/squid/cache.log |
| root@localhost \~# systemctl start squid root@localhost \~# systemctl status squid |
| ● squid.service - Squid caching proxy Loaded: loaded (/usr/lib/systemd/system/squid.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2025-12-03 17:58:35 CST; 7s ago Docs: man:squid(8) Process: 13937 ExecStartPre=/usr/libexec/squid/cache_swap.sh (code=exited, status=0/SUCCESS) Main PID: 13943 (squid) Tasks: 2 (limit: 50660) Memory: 13.1M CGroup: /system.slice/squid.service ├─13943 /usr/sbin/squid --foreground -f /etc/squid/squid.conf └─13945 (squid-1) --kid squid-1 --foreground -f /etc/squid/squid.conf Dec 03 17:58:35 localhost.localdomain systemd1: Starting Squid caching proxy... Dec 03 17:58:35 localhost.localdomain squid13943: Squid Parent: will start 1 kids Dec 03 17:58:35 localhost.localdomain squid13943: Squid Parent: (squid-1) process 13945 started Dec 03 17:58:35 localhost.localdomain systemd1: Started Squid caching proxy. |
| root@localhost \~# netstat -ntlp |
| Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 910/sshd tcp6 0 0 :::22 :::* LISTEN 910/sshd tcp6 0 0 :::3128 :::* LISTEN 13945/(squid-1) |

2.配置内网服务器

|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| root@localhost \~# vim /etc/profile |
| export http_proxy=http://10.9.254.36:3128 export https_proxy=http://10.9.254.36:3128 # 注意:对于HTTPS请求,Squid代理地址通常也是http:// export no_proxy=localhost,127.0.0.1,10.9.254.0/24,.internal.domain.com # 排除不需要代理的内网地址 |
| root@localhost \~# source /etc/profile root@localhost \~# vim /etc/yum.conf |
| proxy=http://10.9.254.36:3128 |
| root@localhost \~# yum repolist |
| repo id repo name appstream Rocky Linux 8 - AppStream baseos Rocky Linux 8 - BaseOS epel Extra Packages for Enterprise Linux 8 - x86_64 extras Rocky Linux 8 - Extras |

相关推荐
Kendra9197 小时前
从 0 到上线:单文件网页 App 部署到阿里云 ECS 全流程(Nginx+Node+PM2+PostgreSQL)
nginx·阿里云·云计算·部署·个人开发·今天吃什么
北极糊的狐11 小时前
阿里云宝塔输入cat /www/server/panel/config/safe_path.conf报错 No such file or directory
阿里云·云计算
北极糊的狐14 小时前
阿里云宝塔报错bash tools/update.sh: No such file or directory 意思是:tools 整个目录直接丢失
阿里云·云计算·bash
NiceCloud喜云14 小时前
阿里云 ECS 实例怎么选:面向出海业务的规格、地域与成本判断
阿里云·云计算
使用小功能大师17 小时前
从零搭建高可用Web应用:全栈架构实战与成本优化完全指南
前端·阿里云·架构·服务搭建
yunlaodacom1 天前
阿里云国际站注册:性能损耗 < 1%!基于 eBPF 的服务器异常预测实战与调优指南
大数据·服务器·阿里云
聚搜云——JuSouClouD2 天前
上海阿里云代理商:AI Agent 云运维 权限隔离与审计实战
运维·人工智能·阿里云
聚搜云——JuSouClouD2 天前
深圳阿里云代理商:云主机性能下滑 诊断优化实战分享
阿里云·云计算
代码AC不AC2 天前
【Linux】NAT与代理
linux·nat·代理