Skip to main content

การกำหนดค่าเครือข่าย

Enterprise proxy, CA certificates, mTLS และข้อกำหนดการเข้าถึงเครือข่าย

Enterprise Proxy

การตั้งค่า Proxy

Claude Code รองรับ HTTP/HTTPS proxy ผ่าน environment variables มาตรฐาน:

export HTTPS_PROXY=https://proxy.example.com:8080
export HTTP_PROXY=http://proxy.example.com:8080
export NO_PROXY=localhost,127.0.0.1,.internal.example.com

หรือตั้งค่าใน settings file:

{
"env": {
"HTTPS_PROXY": "https://proxy.example.com:8080",
"NO_PROXY": "localhost,.internal.example.com"
}
}

Proxy ที่ต้องการ Authentication

export HTTPS_PROXY=https://username:[email protected]:8080

CA Certificates

เพิ่ม Custom CA Certificate

สำหรับ environments ที่ใช้ self-signed certificates หรือ internal CAs:

export NODE_EXTRA_CA_CERTS=/path/to/ca-bundle.crt

หรือสำหรับ Node.js:

export SSL_CERT_FILE=/path/to/ca-bundle.crt

Certificate Bundle Format

CA certificate ควรอยู่ในรูปแบบ PEM:

-----BEGIN CERTIFICATE-----
MIIBkTCB+wIJ...
-----END CERTIFICATE-----

Mutual TLS (mTLS)

สำหรับ environments ที่ต้องการ client certificate authentication:

{
"tlsClientCert": "/path/to/client.crt",
"tlsClientKey": "/path/to/client.key",
"tlsCaCert": "/path/to/ca.crt"
}

ข้อกำหนดการเข้าถึงเครือข่าย

Claude Code ต้องการเข้าถึง endpoints เหล่านี้:

Anthropic API

  • api.anthropic.com (port 443)
  • claude.ai (port 443) - สำหรับ OAuth login

MCP Servers (ตามที่คุณกำหนดค่า)

  • Endpoints ของ MCP servers ที่คุณเพิ่ม

npm Registry (สำหรับ stdio MCP servers)

  • registry.npmjs.org (port 443) - ถ้าใช้ npx servers

Airgapped Environments

สำหรับ environments ที่ไม่มีการเชื่อมต่ออินเทอร์เน็ต:

  1. ใช้ ANTHROPIC_BASE_URL ชี้ไปยัง internal proxy:
export ANTHROPIC_BASE_URL=https://anthropic-proxy.internal.example.com
  1. Pre-populate plugins และ MCP servers ก่อน deployment

  2. ตั้งค่า CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1 เพื่อรักษา cache เมื่อ network ไม่พร้อมใช้งาน

การแก้ไขปัญหาเครือข่าย

ตรวจสอบการเชื่อมต่อ

curl -v https://api.anthropic.com/v1/messages \
-H "anthropic-version: 2023-06-01" \
-H "x-api-key: $ANTHROPIC_API_KEY"

ตรวจสอบ Proxy

curl -v --proxy $HTTPS_PROXY https://api.anthropic.com

Debug Logs

รัน Claude Code ด้วย debug flag เพื่อดู network requests:

claude --debug