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 systemd[1]: Starting Squid caching proxy... Dec 03 17:58:35 localhost.localdomain squid[13943]: Squid Parent: will start 1 kids Dec 03 17:58:35 localhost.localdomain squid[13943]: Squid Parent: (squid-1) process 13945 started Dec 03 17:58:35 localhost.localdomain systemd[1]: 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 |

相关推荐
ZStack开发者社区15 小时前
云边协同 智启未来 | 阿里云 × ZStack 云边一体解决方案正式落地
阿里云·云计算·边缘计算
普通网友15 小时前
阿里云国际版服务器,真的是学生党的性价比之选吗?
后端·python·阿里云·flask·云计算
MonkeyKing_sunyuhua20 小时前
阿里云ECS安装docker compose
阿里云·docker·云计算
翼龙云_cloud1 天前
阿里云代理商:部署OpenClaw高效办公六式 智能打理日常任务
人工智能·阿里云·云计算·openclaw
沉迷学习 日益消瘦1 天前
(windows环境)白嫖阿里云百炼免费 Token 使用 Claude 教程
windows·阿里云·claude·token·百炼
**蓝桉**1 天前
虚拟化学习笔记
阿里云·云计算
Alan GEO实施教练2 天前
专利申请服务选择:企业挑选口碑好合作方策略解析
阿里云
AC赳赳老秦2 天前
OpenClaw阿里云部署实操:多Agent协同,打造云端自动化工作流
人工智能·阿里云·数据挖掘·自动化·云计算·deepseek·openclaw
白狐_7982 天前
我的第一台云服务器:阿里云 ECS 配置记录,以及本地连接后到底能做什么
运维·服务器·阿里云