// 创建NAT网关
aws ec2 create-nat-gateway --subnet-id
// 为私有子网配置路由表
aws ec2 create-route-table --vpc-id
// 将NAT网关作为目标路由到互联网
aws ec2 create-route --route-table-id
// 将私有子网与路由表关联
aws ec2 associate-route-table --subnet-id
// 创建代理EC2实例
aws ec2 run-instances --image-id
// 安装Squid代理软件(例如Ubuntu系统) sudo apt-get update sudo apt-get install squid
// 配置Squid软件代理所有出站流量
vi /etc/squid/squid.conf
// 在文件末尾添加以下内容
http_access allow all
http_port 3128
cache_peer
// 重启Squid服务 sudo service squid restart
// 将私有子网中的EC2实例配置为使用代理
// 在用户数据中添加以下内容
http_proxy=