Proxy VPS

Proxy cho Claude Code, Cline, Aider AI agent 2026

Hướng dẫn cấu hình proxy IPv4 dedicated TND cho 5 AI coding agent: Claude Code, Cline, OpenCode (Continue), Aider, Codex CLI. ENV variable HTTPS_PROXY, verify qua mitmproxy, benchmark latency US-VN, use case rate limit + geo API.

tnd.vn Cập nhật Đăng 6 phút đọc 12 khối lệnh

Proxy cho Claude Code, Cline, Aider AI agent 2026
Mục lục bài viết
  1. 1. Vì sao dev cần proxy cho AI agent
  2. 2. Environment variable HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXY
  3. 3. Cấu hình Claude Code (Anthropic CLI)
  4. 4. Cấu hình Cline (VS Code extension)
  5. 5. Cấu hình OpenCode (Continue.dev)
  6. 6. Cấu hình Aider (Python CLI)
  7. 7. Cấu hình Codex CLI
  8. 8. Verify traffic qua mitmproxy
  9. 9. Benchmark latency US-VN qua TND IPv4
  10. 10. Use case: rate limit, geo API, test scrape giả lập
  11. Tổng kết

Route AI agent Claude Code, Cline, OpenCode, Aider, Codex CLI qua proxy IPv4 dedicated TND

Dev VN dùng Claude Code, Cline, OpenCode, Aider, Codex CLI ngày càng nhiều - và càng dùng càng gặp 2 vấn đề: rate limit theo IP (Anthropic, OpenAI limit per-IP) và latency US-VN trên đường truyền consumer (FPT, Viettel, VNPT). Route AI agent traffic qua proxy IPv4 dedicated US giúp giảm latency (peering tốt hơn) và tách quota theo IP. Bài này hướng dẫn cấu hình HTTPS_PROXY env variable cho 5 AI coding agent phổ biến + verify traffic qua mitmproxy.

Lưu ý pháp lý: Dùng proxy cho AI agent là use case hợp pháp khi: gửi request từ IP mà bạn được quyền dùng (chính chủ, doanh nghiệp), tuân thủ ToS của Anthropic/OpenAI/Google. Theo Luật BVDLCN 91/2025 và Luật ANM 2018, người dùng tự chịu trách nhiệm. Không khuyến khích: tạo nhiều account để né billing/limit, dùng proxy để vi phạm rate limit.

1. Vì sao dev cần proxy cho AI agent

  • Rate limit per-IP: Anthropic/OpenAI có quota theo IP, dùng quá bị 429 Too Many Requests. Proxy fresh IP reset quota.
  • Latency tối ưu: Đường truyền consumer VN sang AWS US thường có hop chậm. TND peering tốt với US backbone, latency ổn định hơn.
  • Geo-restricted API: Một số feature OpenAI/Google chỉ active cho IP US (vd: GPT-4o realtime API).
  • Isolation per project: Mỗi client/project 1 IP riêng, audit clean, không lẫn quota.
  • Test scrape giả lập: AI agent gửi request mô phỏng user thật từ IP US/VN cho QA test.

2. Environment variable HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXY

Hầu hết tool Unix-based (Node.js, Python, cURL, wget) đọc proxy config từ environment variable:

VariableMục đíchFormat
HTTP_PROXYProxy cho request HTTPhttp://user:pass@ip:port
HTTPS_PROXYProxy cho request HTTPS (CONNECT)http://user:pass@ip:port
ALL_PROXYProxy cho mọi protocol (SOCKS5)socks5://user:pass@ip:port
NO_PROXYDomain bypass proxylocalhost,127.0.0.1,*.local

Set trong shell session (bash/zsh):

Terminal2. Environment variable HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXYbash
export HTTPS_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021"export HTTP_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021"export ALL_PROXY="socks5://user123:••••••••@23.155.xxx.xxx:2020"export NO_PROXY="localhost,127.0.0.1,.local"

Permanent: thêm vào ~/.bashrc hoặc ~/.zshrc.

Windows PowerShell:

PowerShell2. Environment variable HTTPS_PROXY HTTP_PROXY ALL_PROXY NO_PROXYpowershell
$env:HTTPS_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021"$env:HTTP_PROXY=$env:HTTPS_PROXY# Permanent: setx HTTPS_PROXY "..."

3. Cấu hình Claude Code (Anthropic CLI)

Claude Code là CLI Node.js của Anthropic. Nó respect HTTPS_PROXY env tự động.

Terminal3. Cấu hình Claude Code (Anthropic CLI)bash
# 1. Set env variableexport HTTPS_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021" # 2. Run Claude Codeclaude # 3. Verify - trong session Claude:/status# Hiển thị: Network: proxy http://...:2021

Hoặc set trong ~/.claude/settings.json:

File cấu hình3. Cấu hình Claude Code (Anthropic CLI)json
{  "proxy": "http://user123:••••••••@23.155.xxx.xxx:2021"}

4. Cấu hình Cline (VS Code extension)

Cline (former Claude Dev) là VS Code extension. Settings > Cline:

  • API Provider: Anthropic / OpenAI / OpenRouter / Custom
  • API Base URL: giữ mặc định
  • Proxy URL: điền http://user123:••••••••@23.155.xxx.xxx:2021

Hoặc set env trước khi mở VS Code:

Terminal4. Cấu hình Cline (VS Code extension)bash
HTTPS_PROXY="http://..." code .

5. Cấu hình OpenCode (Continue.dev)

OpenCode là fork mã nguồn mở từ Continue.dev. Config file ~/.continue/config.json:

File cấu hình5. Cấu hình OpenCode (Continue.dev)json
{  "models": [{    "title": "Claude 3.7 Sonnet",    "provider": "anthropic",    "model": "claude-3-7-sonnet-20250219",    "apiKey": "sk-ant-...",    "requestOptions": {      "proxy": "http://user123:••••••••@23.155.xxx.xxx:2021"    }  }]}

6. Cấu hình Aider (Python CLI)

Aider là Python CLI - dùng env variable hoặc .aider.conf.yml:

File cấu hình6. Cấu hình Aider (Python CLI)yaml
# ~/.aider.conf.ymlopenai-api-base: https://api.openai.com/v1anthropic-api-base: https://api.anthropic.com

Set env variable trong shell trước run aider:

Terminal6. Cấu hình Aider (Python CLI)bash
export HTTPS_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021"aider --model claude-3-7-sonnet-20250219

Aider dùng Python requests + litellm nên auto pick HTTPS_PROXY env.

7. Cấu hình Codex CLI

Codex CLI (OpenAI's terminal-based coding agent) là Node.js. Cấu hình:

Terminal7. Cấu hình Codex CLIbash
export HTTPS_PROXY="http://user123:••••••••@23.155.xxx.xxx:2021"export NO_PROXY="localhost,127.0.0.1"codex

Hoặc trong ~/.codex/config.toml:

File cấu hình7. Cấu hình Codex CLItoml
[network]proxy_url = "http://user123:••••••••@23.155.xxx.xxx:2021"

8. Verify traffic qua mitmproxy

mitmproxy là tool inspect HTTP/HTTPS traffic ở Layer 7 - hữu ích để verify AI agent thực sự đi qua proxy TND.

Terminal8. Verify traffic qua mitmproxybash
# Cài mitmproxypip install mitmproxy # Run local mitmproxy port 8888, upstream tới TNDmitmproxy --mode upstream:http://user123:••••••••@23.155.xxx.xxx:2021 \          --listen-port 8888 # Trong terminal khác, set HTTPS_PROXY về mitmproxy localexport HTTPS_PROXY="http://localhost:8888" # Run Claude Codeclaude # mitmproxy hiển thị mọi request đi qua, bao gồm:# - api.anthropic.com/v1/messages# - upstream qua TND IP 23.155.xxx.xxx

Nếu thấy traffic đi qua mitmproxy + upstream TND, setup đúng.

9. Benchmark latency US-VN qua TND IPv4

Terminal9. Benchmark latency US-VN qua TND IPv4bash
# Test direct (no proxy)curl -o /dev/null -s -w 'DNS: %{time_namelookup}s | Connect: %{time_connect}s | TTFB: %{time_starttransfer}s | Total: %{time_total}s\n' \  https://api.anthropic.com/v1/messages -X POST \  -H "x-api-key: sk-..." -H "content-type: application/json" \  -d '{"model":"claude-3-7-sonnet-20250219","max_tokens":10,"messages":[{"role":"user","content":"hi"}]}' # Test qua TND HTTPHTTPS_PROXY="http://[email protected]:2021" curl -o /dev/null -s -w '...' ... # Test qua TND SOCKS5curl --socks5 [email protected]:2020 -o /dev/null -s -w '...' ...
TuyếnDNSConnectTTFBTotal
VN consumer → Anthropic direct20-50ms200-280ms800-1500ms1.5-3s
VN → TND US → Anthropic1ms (cached)180-220ms500-900ms1-2s
VN → TND VN → Anthropic1ms30ms (local)700-1100ms1.2-2.5s

Lợi thế TND US: stable peering, ít packet loss giờ peak. Lợi thế TND VN: connect nhanh, nhưng vẫn phải qua sea cable đến US server, không nhanh hơn nhiều.

10. Use case: rate limit, geo API, test scrape giả lập

Use case 1: Tránh rate limit per-IP

Bạn chạy AI agent agressively cho 1 project, hit 429 rate limit. Tạm thời switch sang TND IPv4 #2 (1 client = 1 IP), reset quota. Đây là workaround tạm thời, lâu dài cần upgrade plan API.

Use case 2: Geo-restricted API feature

OpenAI GPT-4o realtime voice API chỉ active cho region US. Route Claude Code/Codex qua TND US, API trả về voice endpoint, work bình thường.

Use case 3: Isolation per client/project

Bạn freelance 5 client. Mỗi client 1 TND IPv4 + 1 Anthropic billing account. Audit log clean - mỗi client thấy API call từ IP cố định của họ.

Use case 4: Test geo cho automation user-facing

QA test app từ "góc nhìn user US" - Claude Code route qua TND US, kiểm tra response API có khác với user VN không.

Tổng kết

5 AI agent phổ biến (Claude Code, Cline, OpenCode, Aider, Codex) đều respect HTTPS_PROXY env hoặc có proxy field trong config. Set 1 env variable là route được. TND IPv4 dedicated US là lựa chọn phù hợp cho dev VN: latency US ổn định, IP cố định để build trust với API provider, dedicated 1 user (không bị flag liên đới).

Tham khảo thêm:

Chia sẻ:Facebook

tnd.vn

TND

Tư vấn bản quyền, VPS và máy chủ kèm hóa đơn VAT, hợp đồng đầy đủ cho doanh nghiệp.