포워드 프록시 지원
포워드 프록시 지원 (Forward proxy support)
네트워크가 격리된 환경에서는 AI Gateway가 LLM 제공사나 외부 서비스로 직접 나가는 연결을 맺지 못하는데요, 포워드 프록시 지원을 쓰면 AI Model과 AI MCP Server가 내보내는 요청을 통제된 HTTP 포워드 프록시로 우회시킬 수 있어요. 그래서 추론 트래픽, 시맨틱 작업, 가드레일 검사 같은 기능들이 엄격한 이그레스 정책 아래에서도 그대로 동작해요. 이 문서에서는 프록시가 거치는 세 가지 아웃바운드 요청의 종류와 proxy 설정 필드, 엔티티별 설정 방법, Forward Proxy Advanced 플러그인과의 관계까지 차근차근 안내해요
출처: 문서
본문
포워드 프록시 지원이란 무엇인가요?
네트워크가 격리된 배포 환경에서는 AI Gateway가 LLM 제공사나 보조 서비스로 직접 아웃바운드 연결을 열 수 없어요. 포워드 프록시 지원을 사용하면 AI Model과 AI MCP Server의 아웃바운드 요청을 통제된 HTTP 포워드 프록시를 통해 라우팅할 수 있어서, 엄격한 이그레스 정책 뒤에서도 인퍼런스 트래픽, 시맨틱 작업, 가드레일 검사가 계속 동작해요.
AI Model이나 MCP Server가 발생시키는 아웃바운드 요청은 config에 proxy 레코드를 설정해서 지정된 프록시 호스트를 통해 보낼 수 있어요. 이 레코드에는 프록시 호스트, 포트, 스킴, 제외 호스트, 그리고 선택적으로 자격 증명을 지정해요. 로드 밸런싱, 헬스 체크, 스트리밍, WebSocket, HTTP/2 같은 기존 기능도 계속 동작해요.
포워드 프록시 지원의 동작 방식
AI Gateway는 세 가지 범주의 아웃바운드 요청을 보내요. proxy는 이 세 가지 모두에 적용될 수 있으며, 요청이 시작되는 지점에 따라 서로 다른 메커니즘을 사용해요.
세 가지 요청 범주는 다음과 같아요:
- 인퍼런스: 클라이언트에서 LLM 제공사로 향하는 요청이에요. AI Model이 AI Gateway를 통해 이 요청을 프록싱해요. AI Gateway 트래픽의 대부분이 여기에 해당해요. 포워드 프록시 지원이 활성화된 상태에서도 로드 밸런싱, 헬스 체크, 재시도, 스트리밍, WebSocket, HTTP/2는 모두 계속 동작해요. 포워드 프록시가 활성화되어 있는 동안에는 업스트림 keepalive가 비활성화되기 때문에, 서로 다른 업스트림 피어를 대상으로 하는 요청들 사이에서 인퍼런스 연결이 재사용되지 않아요.
- 아이덴티티 인증: 제공사 SDK가 수행하는 클라우드 아이덴티티 인증이에요. 대상이 관리형 아이덴티티를 요구하는 경우의 AWS Bedrock SigV4 서명, Azure 및 GCP 관리형 아이덴티티 토큰 획득 등이 여기에 포함돼요.
- 보조 호출: 시맨틱, RAG, 가드레일, 새니타이저, 컴프레서 정책이 외부 서비스로 직접 보내는 HTTP 호출이에요. 예를 들면 임베딩 서비스, AWS Bedrock Guardrails, Azure Content Safety, Lakera, GCP Model Armor, 또는 설정된 커스텀 엔드포인트 같은 것들이 있어요.
flowchart LR
Client --> AIModel
Client --> Aux
subgraph Gateway_Group[Kong AI Gateway]
subgraph Policies[AI Entities]
AIModel[AI Model]
Aux[AI MCP Server]
end
end
AIModel -- inference --> Proxy[Forward proxy]
AIModel -- "identity auth" --> Proxy
Aux -- "MCP calls" --> Proxy
Proxy --> LLM[LLM providers]
Proxy --> CloudAPI[Cloud platform APIs]
Proxy --> AuxSvc[Upstream MCP]
style Policies stroke-dasharray: 5 5
그림 1: AI Gateway 정책에서 나오는 아웃바운드 트래픽이 포워드 프록시를 통해 라우팅되는 모습.
AI Model이나 MCP Server 엔티티에 proxy가 설정되면, 해당 엔티티가 발생시키는 모든 아웃바운드 요청이 설정된 프록시를 거쳐가요.
Forward Proxy Advanced 플러그인과의 관계
Kong Gateway는 AI가 아닌 업스트림 트래픽을 중개 HTTP 프록시를 통해 라우팅하기 위한 Forward Proxy Advanced 플러그인도 제공해요. AI가 아닌 서비스에는 Forward Proxy Advanced 플러그인을 사용하세요.
Forward Proxy Advanced 플러그인은 balancer 단계가 실행되기 전에 요청을 가로채요. 이 방식은 표준 Gateway Service에서는 동작하지만, AI Gateway가 의존하는 동작들, 즉 업스트림 로드 밸런싱, 헬스 체크 보고, 재시도, WebSocket 업그레이드, HTTP/2 요청 본문 처리와는 맞지 않아요.
AI Model이나 MCP Server 엔티티를 통과하는 AI Gateway 트래픽에는 대신 기본 proxy 설정을 사용하는 게 좋아요. 그러면 balancer 단계가 정상적으로 계속 실행돼요. 포워드 프록시가 활성화되어 있고 proxy를 설정해 둔 상태에서도 LLM 대상 간 로드 밸런싱, 스트리밍, 실시간 API 트래픽, HTTP/2 인퍼런스 요청은 모두 정상 동작해요.
프록시 설정 필드
AI Model은 config 블록의 최상위 레벨에서 proxy 레코드를 받아들여요. MCP Server는 type이 passthrough-listener인 경우에만 이를 받아들여요. conversion-listener와 listener 타입의 MCP Server는 현재 포워드 프록시 설정을 전혀 지원하지 않아요.
http_proxy
타입: object
설명: HTTP 업스트림에 사용하는 포워드 프록시예요. host와 port 필드를 가진 객체예요.
https_proxy
타입: object
설명: HTTPS 업스트림에 사용하는 포워드 프록시예요. host와 port 필드를 가진 객체예요.
proxy_scheme
타입: string
설명: 포워드 프록시 자체에 연결할 때 사용하는 스킴이에요. 현재는 http만 지원돼요. 기본값은 http예요.
auth
타입: object
설명: 프록시 인증에 사용하는 자격 증명이에요. username과 password 필드를 가진 객체예요. 두 필드 모두 선택 사항이며 AI Vault에서 참조할 수 있어요.
no_proxy
타입: string 설명: 프록시를 거치지 않아야 할 호스트들의 쉼표 구분 목록이에요.
이 레코드에는 두 가지 검증 규칙이 적용돼요:
http_proxy가 설정된 경우host와port모두 설정되어야 해요.https_proxy가 설정된 경우host와port모두 설정되어야 해요.
지원되는 정책
AI Policy에도 config 블록 최상위 레벨에 같은 proxy 레코드를 설정해서 포워드 프록시를 사용하도록 구성할 수 있어요.
다음 AI Policy들이 지원돼요:
임베딩과 시맨틱 작업
Policies: |
- AI Semantic Cache
- AI Semantic Prompt Guard
- AI Semantic Response Guard 프록시 대상: 설정된 임베딩 서비스
프롬프트 압축 및 새니타이제이션
Policies: |
- AI Prompt Compressor
- AI Sanitizer
프록시 대상: 설정된
compressor_url또는sanitizer_url
가드레일 서비스
Policies: |
- AI AWS Guardrails
- AI Azure Content Safety
- AI Lakera Guard
- AI GCP Model Armor
- AI Custom Guardrail 프록시 대상: 관리형 또는 커스텀 가드레일 서비스
설정
포워드 프록시 설정하기
테스트용 간단한 포워드 프록시를 만들 때는 Squid를 사용할 수 있어요.
Squid는 AI Gateway 데이터 플레인 컨테이너와는 별개로 자체 Docker 컨테이너에서 실행돼요. 다음 예제에서 데이터 플레인은 host.docker.internal을 통해 Squid에 접근해요. host.docker.internal은 Docker Desktop과 OrbStack이 컨테이너 내부에서 호스트 머신으로 해석해 주는 특별한 호스트명이에요. 아래 compose 파일이 Squid의 포트를 호스트에 퍼블리시하기 때문에 이런 방식이 동작해요. 그래서 자체적인 별도 Docker 네트워크에서 실행되는 AI Gateway 데이터 플레인을 포함해 어떤 컨테이너든, Docker 네트워크를 공유하거나 머신의 hosts 파일을 수정할 필요 없이 호스트 머신을 거쳐 Squid에 접근할 수 있어요.
프로덕션 배포 환경에서는 포워드 프록시가 AI Gateway를 포함한 사용자를 인증하도록 해야 해요. 이렇게 하려면
auth_username과auth_password를 설정하세요. AI Vault에서 시크릿을 참조할 수 있어요.
-
Squid용 최소 설정 파일을 만드세요:
echo ' # Allow your local machine. Different container runtimes (Docker Desktop, OrbStack, Colima) # allocate bridge networks in different private ranges, so this allows all of them. acl localnet src 10.0.0.0/8 acl localnet src 172.16.0.0/12 acl localnet src 192.168.0.0/16 acl SSL_ports port 443 acl Safe_ports port 80 443 http_access deny !Safe_ports http_access allow localnet http_access allow localhost http_access deny all http_port 3128 access_log /var/log/squid/access.log combined cache_log /var/log/squid/cache.log ' > squid.conf -
docker compose 파일을 만드세요:
echo ' services: squid: image: ubuntu/squid container_name: squid ports: - "3128:3128" volumes: - ./squid.conf:/etc/squid/squid.conf:ro ' > docker-compose.yml -
docker로 Squid를 실행하세요:
docker compose up -d
AI Gateway
Konnect를 사용해 새 AI Gateway를 만들려면 다음 단계를 따르세요:
-
Konnect PAT 페이지에서 Generate Token을 선택해 새 개인 액세스 토큰을 만드세요.
-
토큰을 환경 변수로 내보내세요:
export KONNECT_TOKEN='YOUR_KONNECT_PAT' -
Kong Konnect에 컨트롤 플레인과 로컬 데이터 플레인을 자동으로 프로비저닝하려면 AI Gateway 퀵스타트 스크립트를 실행하세요:
curl -Ls https://get.konghq.com/ai | bash -s -- -k $KONNECT_TOKEN
이렇게 하면 ai-quickstart라는 이름의 AI Gateway 컨트롤 플레인이 설정되고, 로컬 데이터 플레인이 프로비저닝되며, 다음과 같은 환경 변수 export 구문이 출력돼요:
export AI_GATEWAY_ID=your-gateway-id
export DECK_KONNECT_TOKEN=$KONNECT_TOKEN
export DECK_KONNECT_CONTROL_PLANE_NAME=quickstart
export KONNECT_CONTROL_PLANE_URL=https://us.api.konghq.com
export KONNECT_PROXY_URL='http://localhost:8000'
터미널에 복사해 붙여 넣어 세션을 구성하세요.
AI Model
모델과 프로바이더 만들기
Anthropic API 키를 생성한 다음 환경 변수로 내보내세요:
export ANTHROPIC_API_KEY='YOUR_ANTHROPIC_API_KEY'
LLM 서비스를 정의하고 인증 자격 증명을 저장할 AI Provider 엔티티를 만드세요:
kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_model_providers:
- ref: generic-anthropic
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: generic-anthropic
display_name: "generic-anthropic"
type: anthropic
config:
auth:
type: basic
headers:
- name: x-api-key
value: !secret {source: !env ANTHROPIC_API_KEY}
EOF
{: data-test-step="block" }
AI Model 엔티티를 만들고 포워드 프록시 호스트를 지정하세요:
kongctl apply -f - --auto-approve --pat "$KONNECT_TOKEN" << 'EOF'
ai_gateway_models:
- ref: my-claude
ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
name: my-claude
display_name: "my-claude"
type: model
formats:
- type: anthropic
config:
route:
paths:
- /
model:
body_param: model
values:
- my-claude
proxy:
http_proxy:
host: host.docker.internal
port: 3128
https_proxy:
host: host.docker.internal
port: 3128
proxy_scheme: http
targets:
- name: claude-opus-4-8
provider: generic-anthropic
config:
type: anthropic
policies: []
capabilities:
- generate
EOF
{: data-test-step="block" }
검증
-
채팅 요청을 보내세요. 이 요청은 프록시 서비스를 거쳐 Anthropic으로 전달돼요:
curl -X POST "$KONNECT_PROXY_URL/v1/messages" \ --no-progress-meter --fail-with-body \ -H "Accept: application/json"\ -H "Content-Type: application/json"\ -H "Authorization: Bearer $ANTHROPIC_API_KEY" \ --json '{ "model": "my-claude", "max_tokens": 100, "messages": [ { "role": "user", "content": "Say this is a test!" } ] }' -
요청을 검증하려면 Squid 로그를 확인하세요:
docker exec -it squid tail -f /var/log/squid/access.log
AI MCP Server
-
Swagger Petstore 샘플 API를 자체 Docker 컨테이너에서 실행해요:
docker run -d \ --name swagger-petstore-forward-proxy \ -p 8080:8080 \ swaggerapi/petstore3:latest -
Petstore API를 하나의 MCP 도구로 노출하는 AI MCP Server 엔티티를 생성해요:
curl -X POST "https://us.api.konghq.com/v1/ai-gateways/$AI_GATEWAY_ID/mcp-servers" \ --no-progress-meter --fail-with-body \ -H "Authorization: Bearer $KONNECT_TOKEN"\ -H "Content-Type: application/json"\ -H "Accept: application/json, application/problem+json" \ --json '{ "display_name": "Petstore API (forward proxy)", "name": "petstore-forward-proxy-mcp", "type": "conversion-listener", "enabled": true, "policies": [], "access": { "acl_attribute_type": "consumer", "acls": { "allow": [] }, "default_tool_acls": { "deny": [] } }, "config": { "url": "http://host.docker.internal:8080/api/v3", "route": { "paths": [ "/petstore-forward-proxy" ] }, "logging": { "payloads": false }, "server": { "timeout": 60000 } }, "tools": [ { "name": "get-pet-by-id", "description": "Get a pet by ID", "method": "GET", "path": "/petstore-forward-proxy/pet/{petId}", "parameters": [ { "name": "petId", "in": "path", "required": true, "schema": { "type": "integer" }, "description": "ID of the pet to retrieve" } ] } ] }' -
MCP Inspector CLI를 사용해서 MCP 서버가
get-pet-by-id를 도구로 노출하는지 확인해요:npx -y @modelcontextprotocol/inspector@0.22.0 --cli \ http://localhost:8000/petstore-forward-proxy \ --transport http --method tools/list | jq -r '.tools[].name'다음과 같은 출력이 보여요:
get-pet-by-id{:.no-copy-code}
-
이 MCP 서버는
conversion-listener가 포워드 프록시를 지원하지 않기 때문에 포워드 프록시를 통해 라우팅되지 않아요.get-pet-by-id를 호출하면 Petstore에 직접 도달해요:npx -y @modelcontextprotocol/inspector@0.22.0 --cli \ http://localhost:8000/petstore-forward-proxy \ --transport http --method tools/call \ --tool-name get-pet-by-id \ --tool-arg path_petId=7 | jq -r '.content[0].text' | jq -c '.'다음과 같은 응답이 보여요:
{"id":7,"category":{"id":4,"name":"Lions"},"name":"Lion 1","photoUrls":["url1","url2"],"tags":[{"id":1,"name":"tag1"},{"id":2,"name":"tag2"}],"status":"available"}{:.no-copy-code}
제한 사항
- 벡터 데이터베이스(pgvector, Redis Vector, Pinecone 등)로의 연결은 HTTP가 아닌 네이티브 데이터베이스 프로토콜을 사용하기 때문에 포워드 프록시를 통해 라우팅되지 않아요. 이런 연결이 포워드 프록시를 거쳐가야 한다면 네트워크 계층에서 처리하는 게 좋아요.
- AI Request Transformer, AI Response Transformer, AI LLM as a Judge 정책은 기존의 플랫한 프록시 필드(
http_proxy_host,http_proxy_port,https_proxy_host,https_proxy_port)를 그대로 유지하며proxy레코드는 받지 않아요. 또한auth_username,auth_password,proxy_scheme,https_verify를 노출하지 않기 때문에, 이 정책들의 트래픽에는 프록시 인증과 HTTPS 스킴 프록시를 사용할 수 없어요.
관련 리소스
더 알아보기 (Learn more)
proxy설정을 적용해 추론 요청을 포워드 프록시로 우회하는 핵심 엔티티를 소개해요 — AI Models- MCP 아웃바운드 호출에 포워드 프록시를 적용하는 엔티티 문서를 확인해요 — AI MCP Servers
- 이 기능과 관계가 깊은 Forward Proxy Advanced 플러그인의 동작 방식을 살펴봐요 — Forward Proxy Advanced plugin
- 프록시 인증 정보를 시크릿으로 참조할 때 활용할 수 있는 AI Vault 사용법을 알아봐요 — AI Vault
- 포워드 프록시가 적용되는 AI Gateway 전체의 개념과 기능을 훑어봐요 — AI Gateway