跳转至

出口代理

集群提供按需使用的 VPC 出口代理,用于访问 Docker Hub、GitHub、PyPI、Hugging Face 等外部服务。代理不会自动启用,也不会改变节点默认路由。

项目
地址 172.18.0.152:7890
HTTP/HTTPS http://172.18.0.152:7890
SOCKS5 socks5h://172.18.0.152:7890
可用范围 集群 VPC 172.18.0.0/24

只在集群主机内使用

这是 VPC 私网地址,只能在 login01 或已分配的计算节点上使用。不要把端口暴露到 公网,也不要在个人电脑上把它配置成可直接访问的公共代理。

它不是 SSH 加速入口

出口代理用于集群主机访问互联网;login.a.cluster.stelledge.com 用于用户加速 SSH 登录。两者用途不同,不能互相替代。

临时启用 HTTP/HTTPS 代理

在当前 Shell 中执行:

export http_proxy='http://172.18.0.152:7890'
export https_proxy="$http_proxy"
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"

export no_proxy='localhost,127.0.0.1,::1,169.254.169.254,100.100.100.200,172.18.0.0/24,mirrors.cloud.aliyuncs.com,.cluster.stelledge.com,ipa.sh.stelledge.com,031zk14bx23odcfl6eg-uec7.cn-shanghai.nas.aliyuncs.com,oss-cn-shanghai-internal.aliyuncs.com,.oss-cn-shanghai-internal.aliyuncs.com'
export NO_PROXY="$no_proxy"

小写和大写变量同时设置,可兼容大多数命令行工具。NO_PROXY 中的集群、NAS、 FreeIPA、云元数据、阿里云内网镜像与 OSS 内网 Endpoint 必须保留,不能为了缩短配置 而删除。访问对象存储 OSS时不需要出口代理。

验证连通性:

curl -I https://registry-1.docker.io/v2/

Docker Registry 返回 401 Unauthorized 表示已经成功连接,认证失败不是代理故障。

使用 SOCKS5 模式

仅当应用不支持 HTTP 代理或明确要求 SOCKS5 时使用:

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
export all_proxy='socks5h://172.18.0.152:7890'
export ALL_PROXY="$all_proxy"

socks5h 会让代理端解析外部域名。排查应用实际选择了哪种代理模式时,不要同时设置 ALL_PROXY 和 HTTP/HTTPS 代理变量。

关闭代理

unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
unset all_proxy ALL_PROXY
unset no_proxy NO_PROXY

运行 env | grep -i proxy,确认当前会话没有遗留变量。

按需保存配置

建议保存成需要时手动加载的文件,不要默认写入所有登录和作业会话:

mkdir -p ~/.config/stellar
cat > ~/.config/stellar/proxy.sh <<'EOF'
export http_proxy='http://172.18.0.152:7890'
export https_proxy="$http_proxy"
export HTTP_PROXY="$http_proxy"
export HTTPS_PROXY="$https_proxy"
export no_proxy='localhost,127.0.0.1,::1,169.254.169.254,100.100.100.200,172.18.0.0/24,mirrors.cloud.aliyuncs.com,.cluster.stelledge.com,ipa.sh.stelledge.com,031zk14bx23odcfl6eg-uec7.cn-shanghai.nas.aliyuncs.com,oss-cn-shanghai-internal.aliyuncs.com,.oss-cn-shanghai-internal.aliyuncs.com'
export NO_PROXY="$no_proxy"
EOF
chmod 600 ~/.config/stellar/proxy.sh

需要时启用:

source ~/.config/stellar/proxy.sh

新的 Shell 不会自动继承该设置。确需为每次登录启用时,可以在 ~/.bashrcsource 此文件,但应先确认不会影响内部服务和日常作业。

常用工具

大多数工具会自动读取上述环境变量:

source ~/.config/stellar/proxy.sh
git clone https://github.com/ORG/REPOSITORY.git

优先使用环境变量,不建议设置永久的 git config --global http.proxy。永久配置 容易在代理不可用或访问内部 Git 服务时造成难以发现的故障。

source ~/.config/stellar/proxy.sh
python -m pip install PACKAGE
source ~/.config/stellar/proxy.sh
curl -LO https://example.com/file.tar.gz
wget https://example.com/file.tar.gz
source ~/.config/stellar/proxy.sh
sbatch --export=ALL job.sh

sbatch 默认会携带当前环境;显式写出 --export=ALL 可以表明该作业需要继承 代理变量。多节点作业的每个节点都必须能够访问 VPC 代理。

容器镜像和作业

Pyxis/Enroot 导入外部镜像时,可以在提交前启用代理:

source ~/.config/stellar/proxy.sh
srun \
  --account=project-example \
  --partition=gpu-full \
  --gres=gpu:h20:1 \
  --time=00:10:00 \
  --container-image=docker.io#nvidia/cuda:12.8.1-base-ubuntu22.04 \
  nvidia-smi -L

镜像导入是否使用代理还取决于运行时和当前节点配置。失败时先用本页的 curl 探针 验证网络,再保留完整镜像名和作业编号交给管理员。

使用边界

  • 只在直接访问失败且确有需要时启用,用完后关闭。
  • 大型数据集优先使用项目提供的镜像、对象存储或 /project 数据副本,不要反复从 公网下载。
  • 不要修改 /etc/environment、系统服务或 APT 的全局代理;需要系统包时联系管理员。
  • 不要在脚本、仓库或日志中写入代理服务凭据。当前用户配置不需要用户名和密码。
  • 代理可达不代表目标服务授权成功;HTTP 401403 需要结合目标服务判断。