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 |

相关推荐
froyoisle20 小时前
阿里云免费 SSL 证书申请及配置
服务器·阿里云·ssl·网站
烦德恒2 天前
本地五恒系统五恒品牌哪家好
阿里云
全云在线allcloudonline3 天前
上海阿里云代理商怎么选?跨区域交付能力核验清单
阿里云·云计算·企业上云
阿斯科阀门3 天前
惠州自动化阀门厂家
阿里云
Database_Cool_3 天前
记忆张量MemOS + 阿里云PolarDB一站式记忆管理方案发布:给AI装上不断片的记忆
数据库·人工智能·阿里云
Database_Cool_3 天前
阿里云 Lindorm vs Elasticsearch 检索存储一体对比:多模数据库一站式方案首选
数据库·阿里云
云布道师3 天前
AutoMQ x 阿里云 OSS Tables:基于 Iceberg 构建流表一体的实时入湖
阿里云·云计算
盛夏绽放3 天前
Proxy与Reflect详解(一):基础篇——告别defineProperty的新一代响应式基石
proxy·proxy模式·代理
Database_Cool_4 天前
数据仓库弹性扩缩容怎么实现?AnalyticDB MySQL 在线扩容 0 中断实战
数据库·数据仓库·mysql·阿里云