Vercel Sandbox 방화벽이 이제 요청 프록시 및 필터링을 지원합니다
Source: Vercel Blog
Vercel Sandbox 방화벽이 이제 특정 HTTP 요청을 사용자가 제어하는 프록시로 전달하는 것을 지원합니다. 또한 매처를 사용하여 전달 및 자격 증명 중개를 필요한 요청에만 필터링할 수 있습니다.
Requests proxying
아웃바운드 샌드박스 트래픽을 로깅, 디버깅, 혹은 요청 및 응답을 변환하기 위해 자체 프록시를 통해 라우팅할 수 있습니다. 허용된 도메인에 forwardURL을 설정하면 방화벽이 일치하는 HTTPS 요청을 귀하의 서버로 전달합니다.
프록시는 원본 요청과 함께 소스를 식별하기 위한 추가 헤더를 받습니다:
vercel-forwarded-host: 원본 요청의 SNIvercel-forwarded-scheme: 원본 요청의 스킴vercel-forwarded-port: 원본 요청의 포트vercel-sandbox-oidc-token: 프록시가 요청을 인증하고 소스 팀 / 프로젝트 / 샌드박스를 식별하는 데 사용할 수 있는 Vercel‑발행 OIDC 토큰. 자세한 내용은 docs에서 확인하세요.
import { Sandbox } from '@vercel/sandbox';
// Sandbox has access to everything, with a proxy for requests towards github.com
const sandbox = await Sandbox.create({
networkPolicy: {
allow: {
"github.com": [
{
forwardURL: "https://my-custom-proxy.vercel.app/api/proxy"
}
],
// Allow traffic to all other domains. If unset only defined ones are reachable.
"*": []
}
}
});
Filtering
이제 매처를 사용하여 특정 경로, 메서드, 쿼리 문자열 또는 헤더와 일치하는 요청에 대해 요청 전달 또는 credentials brokering을 필터링할 수 있습니다. 이를 통해 어떤 요청이 변환될지 세밀하게 제어할 수 있습니다; 예를 들어, 특정 API 경로에 대한 POST 요청만 전달하고 나머지 트래픽은 그대로 두는 식입니다.
import { Sandbox } from '@vercel/sandbox';
// Sandbox has access to everything, with a proxy for POST requests to api.github.com/v1/*
const sandbox = await Sandbox.create({
networkPolicy: {
allow: {
"api.github.com": [
{
match: {
path: { startsWith: "/v1" },
method: ["POST"]
},
forwardURL: "https://my-custom-proxy.vercel.app/api/proxy"
}
],
// Allow traffic to all other domains. If unset only defined ones are reachable.
"*": []
}
}
});
이 기능은 Pro 및 Enterprise 플랜에 대해 베타 버전으로 제공됩니다. @vercel/sandbox@beta SDK를 설치하여 시작하고, requests proxying 및 matchers에 대한 자세한 내용은 문서를 참고하세요.