出口代理¶
只有访问 Docker Hub、GitHub、PyPI 等外部服务遇到网络问题时才需要启用代理。 代理仅供集群内网使用,不是 SSH 登录入口,也不会自动开启。
先按当前登录站点设置 PROXY_HOST:
然后在同一个 Shell 中执行:
export http_proxy="http://$PROXY_HOST: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,172.19.0.0/24,mirrors.cloud.aliyuncs.com,.cluster.stelledge.com,ipa.sh.stelledge.com,.nas.aliyuncs.com,oss-cn-shanghai-internal.aliyuncs.com,oss-cn-shenzhen-internal.aliyuncs.com'
export NO_PROXY="$no_proxy"
curl -I https://registry-1.docker.io/v2/
Docker Registry 返回 HTTP 401 Unauthorized 表示网络连接成功。NAS、OSS、
FreeIPA 和云元数据应直接走内网,不要通过代理。提交需要代理的作业时,在
同一个 Shell 中执行 sbatch --export=ALL job.sh,让作业继承环境变量。
如果应用只支持 SOCKS5,可以先取消 HTTP/HTTPS 变量,再设置:
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
export all_proxy="socks5h://$PROXY_HOST:7890"
export ALL_PROXY="$all_proxy"
不要同时设置 HTTP/HTTPS 和 ALL_PROXY 来排查问题。使用完毕后关闭:
代理是按需设置,不建议写入系统全局配置或默认加载的 Shell 配置。