装了 codex ,本地通过如下方法可以使用代理,然后使用 codex
export HTTP_PROXY="socks5://127.0.0.1:1080" export HTTPS_PROXY="socks5://127.0.0.1:1080" code &
我的使用场景是需要链接服务器,在服务端挂载这个代理呢?
![]() | 1 jayeli 1 天前 ssh 端口映射? ssh -N -R |
2 faoisdjioga OP |
3 aarones 1 天前 试一下把这个代理环境变量加到/etc/profile 下面,改好再重新连接 |
4 faoisdjioga OP # 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. |
5 faoisdjioga OP 用他,注意是在 Remote-Server { "http.proxy": "http://127.0.0.1:1080", "http.proxyStrictSSL": false, "http.systemCertificates": false } |