# 1. Create a global proxy agent file
mkdir -p ~/.vscode-server/extensions
cat > ~/.vscode-server/extensions/proxy-agent.js <<'EOF'
const { setGlobalDispatcher, ProxyAgent } = require('undici');
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY;
if (proxy) {
console.log('[VSCode Proxy] Using proxy:', proxy);
setGlobalDispatcher(new ProxyAgent(proxy));
}
EOF
# 2. Export proxy and Node options globally
echo 'export HTTP_PROXY="socks5://127.0.0.1:1080"' >> ~/.bashrc
echo 'export HTTPS_PROXY="socks5://127.0.0.1:1080"' >> ~/.bashrc
echo 'export NODE_OPTIONS="--require ~/.vscode-server/extensions/proxy-agent.js"' >> ~/.bashrc
source ~/.bashrc
因为没有 root ,chatgpt 给了我一个方式成功了。chatgpt 的解释为
🧠 1. What the problem really was
When you run VS Code Remote SSH, the “editor” part runs on your Mac,
but the extensions (ChatGPT, Copilot, Supermaven, R, etc.) run on the remote Linux server inside a Node.js process called the extension host:
VSCode (Mac)
└── SSH tunnel
└── vscode-server (Ubuntu)
└── node --type=extensionHost
└── openai.chatgpt-0.4.19-linux-x64
That Node process makes its own outbound HTTPS calls (to
api.openai.com, etc.).
By default, it doesn’t inherit your system or VS Code proxy because:
VS Code starts that process with --useHostProxy=false (no host proxy forwarding)
Node’s internal HTTP client ignores http.proxy from VS Code settings
Therefore → all extension network traffic bypasses your proxy
So the ChatGPT / CodeX extension couldn’t reach the Internet unless the server itself had open access.